Test.html:
<!DOCTYPE HTML><HTMLLang= "en"Ng-app><Head> <MetaCharSet= "UTF-8"> <title>Document</title></Head><Body> <DivNg-controller= "Helloangular"> <P>{{Greeting.text}},angular</P> </Div></Body><Scriptsrc= "Http://cdn.bootcss.com/angular.js/1.0.3/angular.min.js"></Script><Scriptsrc= "Helloangular.js"></Script></HTML>
Ng-app says: Tell the Angular engine to start here is what it should manage
Ng-controller: Setting controller controllers
which
<ng-controller= "Helloangular"> <P >{greeting.text}},angular</p> </Div >
Is the view
Helloangular.js:
function Helloangular ($scope) { = {text: ' Hello '};}
which
Helloangular
is the controller ,
$scope. Greeting = {text: ' Hello '};
is the data Model .
$scope acts as a data-model in MVC, it is a POJO (Plain old Javascript Object), which provides some tool methods $watch ()/$apply (), which is the execution environment (or scope) of the expression. It is a tree structure, parallel to the DOM tag , the child $scope object inherits the attributes on the $scope , each Angular application has only one root $scope object (typically located on Ng-app), $scope can propagate things , similar to DOM events, can be up or down.
Angular automatically injects $scope objects using $injector
Output:
Hello,angular
AngularJS First Notes