I'm using Angular new router components and also js. I have multiple controllers as the one bellow.
What I'm trying to do is to apply a function to this for all controllers, do I don't have to do it in each one.
function HomeController (authService, factoryClient) {
console.log ('this is home controller');
this = doCommonController.bind(this); //generates an error
//here this should contain currentUser, authService, logout and testVar
console.log(this);
}
and the function is:
var doCommonController = function (authService, currentUser) {
this.testVar = 'value';
this.authService = authService;
this.currentUser = currentUser;
this.logout = this.authService.logout;
}
Also, how do I pass authService and factoryClient from controller to be available in doCommonController?