Advertise with us

How to use ng-controller and ng-model in Angular JS?

Posted by  Anupam Mishra
 1444  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.
  1. Re: How to use ng-controller and ng-model in Angular JS?

    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"/>