Latest web development tutorials

AngularJS ng-controller instruction

AngularJS Reference Manual AngularJS Reference Manual


AngularJS examples

Adding controller application variables:

<Div ng-app = "myApp " ng-controller = "myCtrl">

Full Name: {{firstName + " " + lastName}}

</ Div>

<Script>
var app = angular.module ( 'myApp', []);
app.controller ( 'myCtrl', function ($ scope) {
$ Scope.firstName = "John";
$ Scope.lastName = "Doe";
});
</ Script>

try it"

Definition and Usage

ng-controller instructions for adding a controller for your application.

In the controller, you can write code, making the functions and variables, and use the scope object to access.


grammar

<Element ng-controller = "expression "> </ element>

All HTML elements are supported.


Parameter Value

value description
expression Controller name.

AngularJS Reference Manual AngularJS Reference Manual