there are ng-controller in Angularjs, which allows the DOM element to be mounted on a controller.
such as this:
<div ng-controller= "Firstcontroller" > <p ng-bind= "i" ></p> <input type= "text" ng-model= "abc" val Ue= "" > <p ng-bind= "abc" ></p> </div>
This means that the scope of the controller is the entire div, the contents of which are controlled by the controller named Firstcontroller. In this piece of code,
<p ng-bind= "I" ></p>
equivalent to {{i}}, but I this variable is not defined yet. So you define it in the controller:
<script type= "Text/javascript" >var Firstcontroller = function ($scope) {$scope. i = 0;} </script>
Firstcontroller as a function, $scope is its scope, note that $scope can not be changed to another variable name, which is dedicated.
<input type= "text" ng-model= "abc" value= "" >
It's actually equivalent to automatically adding a variable ABC to the Firstcontroller function.
Above is only the use of the Angularjs 1.2.x version, in the high version, This method is forbidden, because this way will let controller flying, the level of confusion, everything hangs in $ On the Rootscope.
<! doctype html>
This article is from the "Pomelo Juice Front End" blog, please make sure to keep this source http://iampomelo.blog.51cto.com/10193513/1658455
AngularJS Study notes (ii)