Scope Scope
Scope Scope is the link between the HTML View and the Js Controller
Scope is an object that has properties and methods available
Root scope
All applications have a $rootScopethat can function in All of the HTML elements contained in the NG-APP directive
$rootScope is the bridge of scope in each controller , with rootscope Defined values can be used in each controller
AngularJs Controller
AngularJs Controller Controls the AngularJs data
Methods of the Controller
The AngularJs controller assigns variables by $scope , or it can use methods
Controller files are generally decentralized in an external js file named xxxcontroller.js
<Body> <DivNg-app= "Home"> <DivNg-controller= "Index">{{myName ()}}</Div> </Div> </Body> <Scripttype= "Text/javascript"> //instantiate Application object, parameter: module name, empty array varapp=Angular.module ("Home",[]); //Call the Controller () method of the Application objectApp.controller ("Index",function($scope) {$scope. MyName=function(){ return "Tao"+"Shihan"; } }); </Script>
[Angularjs] ANGULARJS series notes (iv) controller