I. Scope of ANGULARJS
<!DOCTYPE HTML><HTMLNg-app><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"><title>Angular overview</title><Scriptsrc= "Angular.min.js"></Script><Script>functionAaa ($scope, $rootScope) {//plus $rootscope This can be an age display, the equivalent of a global scope$scope. Name= 'Hello'; $scope. Age= ' +';}functionBBB ($scope) {$scope. Name= 'Hi';}</Script></Head><Body><DivNg-controller= "Aaa"> <P>{{Name}}</P> <DivNg-controller= "BBB"> <P>{{Name}}</P> <P>{{Age}}</P> </Div></Div></Body></HTML>
<!DOCTYPE HTML><HTMLNg-app><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"><title>Angular overview</title><Scriptsrc= "Angular.min.js"></Script><Script>functionAaa ($scope, $rootScope) {//plus $rootscope This can be an age display, equivalent to a global$scope. Name= 'Hello'; $scope. Age= ' +'; //$rootScope. Age = ' 20 '; This is the final, if there is no age,aaa under the BBB, then age is equal to this value, if the global is not, then this age is really not}functionBBB ($scope) {$scope. Name= 'Hi'; $scope. Age= ' -'; //This property is also added here, the result is}</Script></Head><Body><DivNg-controller= "Aaa"> <P>{{Name}}</P> <DivNg-controller= "BBB"> <P>{{Name}}</P> <P>{{Age}}</P> </Div></Div></Body></HTML>
Ii. Dependency Injection
<!DOCTYPE HTML><HTMLNg-app><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"><title>Untitled Document</title><Scriptsrc= "Angular.min.js"></Script><Script> functionAaa ($scope, $rootScope) {//The parameters must be such that they cannot be modified.Alert (123); }</Script></Head><Body> <DivNg-controller= "Aaa"> </Div></Body></HTML>
Scope and Dependency injection of ANGULARJS