Monday, November 23, 2015

ng-model is not working in ng-include in AngularJs

i have split my layout and used ng-include and noticed that my scope is suddenly stop working in ng-include!, to overcome this problem i used $parent  like this. 

<input type=text ng-model="$parent.Contact.EmailAddress" />

It works great!

Find Volume

Volume is the amount of 3-dimensional space an object occupies.

             5in

   +--------+
  /        /|
 /        / |  5in
+--------+  |
|        |  |
|        |  +
|        | /
|        |/  5in 
+--------+



formula:
Length x Width x Height = Volume
5x5x5 = 125
Capacity of containing 125 object of cubic in. 

Tuesday, November 17, 2015

CSS background Stretch

Set the background-size property to the element. 
 
body {
    background-size: 100% auto; 

}

Sunday, November 15, 2015

Asp.net MVC - Application Architecture


Don't directly call your database in controller.

In your Asp.net MVC Application, you should not place your database logic inside your controller actions. Mixing your database and controller logic makes your application more difficult to maintain over time. It is recommended that you place your database logic in separate repository layer.

Don't directly call your repository in controller. 

You should create another separate layer called service layer or business logic layer, and put your application business logic. roles and validations. Service layer communicates with the repository layer, process the data into information and pass it the controller.

Don't coupled your service layer with controller.

You should isolate your service layer with controller. Service layer must be in-depended, means it should not depended on the plate-form depended objects. So any application can use it without worrying about frame-work version and plate-form.
for example: The service layer should be able to use in WinForms , WebForms , WPF or Asp.net MVC Applications.

Don't put your UI Logic in controller.

UI may have some kind of logic, such as, display the user panel if the user is logged In, show/hide buttons, show the publish button if the publisher is logged in and so on. This logic may have several conditions, functions and properties, We should avoid to put the UI logic directly in our controller because controller is not responsible for handling the logic, but the application flow.
Mixing your application flow and UI/Business logic makes more difficult to maintain your application. We should separate our UI Logic in form of view models, and view models should be called by controller.
Controller is responsible for taking the input from user and pass it to the view models, view model take the input from controller, apply some UI logic if needed, and pass it to he service layer, service layer process it and pass it to repository, and repository is responsible for manipulate the database. 



Friday, November 13, 2015

Posting JSON data to WebAPI Always Null

I was playing with the JQuery and WebAPI and posting some data in JSON format to the Action.
In the Post Action of WebApi Controller [FormBody] Attributes catches the data, and we cast it in our respective type. I felt that send data in  JSON / JSON.stringify() so i must be cast in String type. but i get my data always null?

After several tries i changed the string type to dynamic and it solved my problem! :) 

public void Post([FromBody]dynamic value)
{
}


Uncaught Error: [$injector:modulerr] AngularJS Error in console - Google Chrome.

While using routing in AngularJS, sometime we face this error in our console. 
 Uncaught Error: [$injector:modulerr]

The problem was caused by missing inclusion of ngRoute module. 

Reference this link to your page may solve this problem. 

  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular-route.min.js"></script>