Questions about the AngularJS life-cycle and life-cycle hooks, $ngInit, $onDestroy, etc.
Questions tagged [angularjs-lifecycle]
5 questions
3
votes
2 answers
How to put listen over $destroy while using controllerAs syntax in angular
Now I'm getting rid of $scope dependency from my angular controller to ensuring that I could easily migrate my code to Angular2. My current angular version is 1.4.X.
While doing the same thing there is place while I placed $destroy listener over my…

Pankaj Parkar
- 134,766
- 23
- 234
- 299
3
votes
1 answer
Lifecycle hook this.$postLink gives typeerror
I'm trying to learn angular 1.5 component and have stumbled into a problem. The following code is my startup layout of my component, which compiles without errors with my gruntjob.
angular.module('layout',[]).component('kiHeaderParallax',{
…

Rudi Ørnhøj
- 221
- 3
- 12
3
votes
2 answers
AngularJS - Accessing ng-init variables from run method
1) I have variables initialized in ng-init
Eg -
ng-init="password='Mightybear'";
2) I want to access it from the .run method.
Eg -
anguar.module("ngApp", [])
.run(function() {
//Access password here
});
Below scenarios I have tried, and did…

gopal rao
- 293
- 1
- 12
1
vote
2 answers
Error: $rootScope:inprog -- What is the correct way to 'not' execute $apply in angular?
AngularJS Wiki - Anti-Patterns states the following:
Don't do if (!$scope.$$phase) $scope.$apply(), it means your $scope.$apply() isn't high enough in the call stack.
And I kind of understand this. There is a built in logic that determines when…

David Gustavsson
- 597
- 4
- 25
0
votes
2 answers
Is "$onInit", more efficient way than "activate" to activate "controller" in angularJS?
I'm new to angularJS and want to implement the efficient thing for my project but got stuck between $onInit (life cycle hook) and activate().

fahad tufail
- 555
- 4
- 10