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
En esta página del sitio puede ver el video en línea AngularJS Tutorial 20 - Controller As Syntax de Duración hora minuto segunda en buena calidad , que subió el usuario Nisha Singla 11 febrero 2017, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 853 veces y le gustó 17 a los espectadores. Disfruta viendo!