AngularJS makes your HTML very declarative. However, seeing the functions invoked in your HTML may not offer any clues as to what controller defines said functions. This video offers an approach to solving this problem by returning the controller in the controller definition so that we can opt for something like ng-click="SomeCtrl.doesSomething()"
instead of simply writing ng-click="doesSomething()"
.
Isn't it the same as ControllerAs
syntax?
Isn't it the same as
ControllerAs
syntax?
Basically.
It's kinda like this:
app.controller('AppCtrl', function AppCtrl(){
AppCtrl.prototype.sayHi = function(){
alert('hi');
}
});
right?