In this video we have discussed about Controller As syntax in angular JS
In my previous video we have learnt about nested controller in that child controller will inherit the data from its parent scope.
When you bind the property on $scope in nested controller you will unexpected output
So everytime when you access property inside parent scope you have to access the property using $parent property in angularjs.
But this lead to again lot of confusion because with each level deep you need to add $parent for immediate parent. so in this case it is very difficult to remember the scope of controller
So to get rid from this issue you can create an alias of your controller so that wherever you want to access parent scope , all you need to use mention the alias name that will act like a object
So first rule to create Controller-As Syntax is you need to bind the properties of controller on this rather then $scope object.
app.controller("ParentController",function(){
this.username ='John'
});
Now when you use ng-controller directive inside index.html you need to create alias as well using "AS" keyword
parentController as parent
Visit complete playlist on angular js @ • AngularJS Tutorial 1 - Introduction
Visit my facebook page@
/ angularjs4beginners
Nesta página do site você pode assistir ao vídeo on-line AngularJS Tutorial 20 - Controller As Syntax duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Nisha Singla 11 Fevereiro 2017, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 853 vezes e gostou 17 espectadores. Boa visualização!