An Alternative Approach to Controllers

InstructorJohn Lindquist

Share this video with your friends

Send Tweet

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()".

Dmitri
~ 9 years ago

Isn't it the same as ControllerAs syntax?

Joel Hooks
~ 9 years ago

Isn't it the same as ControllerAs syntax?

Basically.

Aviad Shikloshi
~ 9 years ago

It's kinda like this: app.controller('AppCtrl', function AppCtrl(){ AppCtrl.prototype.sayHi = function(){ alert('hi'); } });

right?