POSTED IN Angularjs

Angularjs controller with example.

Hi, In this tutorial I am going to explain how to use ” Controller “ and scope of the controller in angular js.

Controller is javascript Constructor function. That is used to make the anguler scope.

ng-app -> will specify that you are going to use angular js in this page. You can use in either body[ <body ng-app=””> ] or particluar div [ <div ng-app=””> ]

ng-controller is used to create the controller for particular module.



Controller inside the Controller [ Nested Controller]

We can use nested ng-controllers in angularjs.


 Angularjs Code

$scope -> used to bind the value into view.
$ -> name is variable. by using the object $scope we declaring the variable for Controlle and can assign the value.

Call or Invoke the Controller inside the Controller.

By using $injector object we can invoke or call the controller inside the controller.

Below example clearly tells how to call the controller inside the controller.

HTML Code :

 Angularjs Script

Lets start with Controller use.

Sample program for how to use Controller.

Attributes  used in this program.

1. ng-controller
2. ng-model
3. ng-binding
4. ng-repeat
5. ng-click

HTML Code:

 Angular Code :


Thanks!. If you like this article don’t forget to share and comment.