AngularJS Directives

AngularJS Filters and Elements

AngularJS Tutorials

Controllers in Angular




AngularJS controllers control the data of AngularJS applications. In other words, AngularJS applications are controlled by controllers. The ng-controller directive defines the application controller. It is created by a standard JavaScript object constructor. We can add methods to our controller.




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


Further Explanation:-


Value Description
expression The name of the controller.


Example Explanation:-


The AngularJS application is defined by  ng-app="angular_app". The application runs inside the < div >.

  1. The ng-controller="person_controller" attribute is an AngularJS directive. It defines a controller.
  2. The person_controller function is a JavaScript function.
  3. AngularJS will invoke the controller with a $scope object.
  4. The controller creates two properties (variables) in the scope (first_nameand last_name).
  5. The ng-model directives bind the input fields to the controller properties (firstName and lastName).
  6. Finally, we call fullname() to get the full name.

Code Explanation

All Tutorials related to AngularJS Tutorials

All Sections related to AngularJS