Open amritk opened 8 years ago
If you are using a templateUrl, your lifecycle hooks don't get triggered. This works:
angular.module('app.about', []).directive('about', AboutRoute); function AboutRoute() { return { template: 'About {{ vm.name }}', controller: AboutController, controllerAs: 'vm' }; } function AboutController() { console.log('controller loaded'); } AboutController.prototype.$routerOnActivate = function(toRoute, fromRoute) { console.log('hook triggered'); this.name = toRoute.params.name; }
While this doesn't:
angular.module('app.about', []).directive('about', AboutRoute); function AboutRoute() { return { templateUrl: 'about.html', controller: AboutController, controllerAs: 'vm' }; } function AboutController() { console.log('controller loaded'); } AboutController.prototype.$routerOnActivate = function(toRoute, fromRoute) { console.log('hook triggered'); this.name = toRoute.params.name; }
If you are using a templateUrl, your lifecycle hooks don't get triggered. This works:
While this doesn't: