Home > DeveloperSection > Forums > How to use ng-controller and ng-model in Angular JS?
Anupam Mishra

Total Post:135

Posted on    February-23-2016 10:36 PM

 Angular JS JavaScript  HTML  Angular JS  Angularjs Controller 

 1 Reply(s)
 651  View(s)
Rate this:
Hi everyone,

How to use  ng-controller and ng-model in Angular JS in ASP.NET MVC 4 .Please can anyone give me a solution .

Thank you.

Manoj Bhatt
Manoj Bhatt

Total Post:154

Posted on    February-24-2016 12:18 AM

Here we have  “Customer” controller which provides data via “CustomerName” and “CustomerCode” property and Add/ Update logic to save the data to database.
Controllers” are simple javascript function which provides data and logic to HTML UI. As the name says controller they control how data flows from the server to HTML UI.

function Employee($scope)
        $scope.FirstName = "Anupam";
        $scope.EmployeeCode = "1001";
        $scope.Add = function () {
        $scope.Update = function () {

ng-controller” is a directive.Controllers are attached to the HTML UI by using the “ng-controller” directive tag and the properties of the controller are attached by using “ng-model” directive. For example below is a simple HTML UI which is attached to the “Employee” controller via the “ng-controller” directive and the properties are binded using “ng-model” directive.

<div ng-controller="Employee">
<input type=text id="FirstName"  ng-model="FirstName"/><br />
<input type=text id="EmployeeCode"  ng-model="EmployeeCode"/>

Don't want to miss updates? Please click the below button!

Follow MindStick