Shared Tutorials

Tutorials Shared by the Internet Community

Advertisements

  Top Tutorials     New Tutorials     Submit     Login     Register  

Tutorial Basic Detail

Understanding Controllers in AngularJS

AngularJS is built upon Model View Controller Architecture. So whatever you specify in the html elements using directives will have a controller.
http://www.programming-free.com/2013/10/understanding-controllers-in-angularjs.html

Description:

This article is a continuation of the series of articles written on AngularJS. In the previous post, we saw what is AngularJS and with a basic understanding of AngularJS Directives, let us now proceed to learn Controllers in AngularJs. AngularJS is built upon Model View Controller Architecture. So whatever you specify in the html elements using directives will have a controller at the backend that binds model with the view.

Controllers are Javascript functions that contains the business logic and binds view to model. There is one more thing you should know at this point of time and it is about the 'Scope' object. Scope ($scope) is nothing but a javascript object that glues your view with model data. They hold the model data that is to be presented to the view. If you take a look at the above image, it is clear that the controller 'FooCtrl' is binded to the HTML element using 'ng-controller' directive and '$scope' object hold the data to be provided to this html element. Let us now try to understand this better with a practical example.

Rating Detail

 Stars  Percentage  Total Vote
 One star  Vote LeftVote MiddleVote Right 29.2%  80
 Two starsTwo star  Vote LeftVote MiddleVote Right 7.3%  20
 Three starsThree starsThree stars  Vote LeftVote MiddleVote Right 10.22%  28
 Four starsFour starsFour starsFour stars  Vote LeftVote MiddleVote Right 9.49%  26
 Five starsFive starsFive starsFive starsFive stars  Vote LeftVote MiddleVote Right 43.8%  120

Caste Your Vote

 Rating  Selection  Guidelines
 Poor:     Very disappointing, useless.
 Fair:     Below average, disappointing but not useless.
 Good:     About average in its class.
 Very Good:     Above average for its category.
 Excellent:     One of the best Tutorials in its category.





Advertisements