Questions tagged [lifecycle-hook]

36 questions
28
votes
2 answers

How to implement multiple lifecycle hooks for an Angular2 component?

I know that when defining components in Angular2 you have multiple types of lifecycle hooks that you can implement such as OnDestroy, NgOnInit, etc. In every sample piece of code I've seen online about using these hooks, I only ever see them being…
SemperCallide
  • 1,629
  • 2
  • 21
  • 37
6
votes
6 answers

Invoke a script on EC2 termination

I have to take certain actions during AWS autoscaling scale-in event.The ec2 instance should be able to save some logs and reports to S3 bucket. This can take anywhere between 5 to 15 mins. I already have a script that gets called on termination: ln…
rahul gupta
  • 158
  • 1
  • 3
  • 10
6
votes
1 answer

{{ call() }} in template executes the method block multiple times?

Here the statements in test method is called multiple times. Why is this happening? Is DOM is recreated by AngularJS2 multiple times? import { Component } from '@angular/core'; @Component({ selector: 'my-app', template: `
Method Call…
Prajeet Shrestha
  • 7,272
  • 3
  • 29
  • 51
3
votes
4 answers

Angular 4 : Difference between ngDoCheck vs ngAfterViewChecked

In Angular 2+, ngDoCheck and ngAfterViewChecked seems to perform same function. ngDoCheck is said to be called whenever change detection is triggered. Now this change detection will be triggered with change in View. As per docs, ngAfterViewChecked…
harsrawa
  • 363
  • 4
  • 13
3
votes
1 answer

How do I run a function on ngOnInit() only once and not again upon returning back from another routerLink?

HomeComponent ngOnInit() { console.log('loaded'); this.retrieveData(); } retrieveData() { // this.dataService.getData().subscribe(...); } I am retrieving data when the component loads. When the user clicks on another routerLink, for…
anonym
  • 3,202
  • 6
  • 32
  • 56
2
votes
2 answers

How to use OnDestroy properly

I've seen a lot of question related to ngOnDestroy. I think many of us not using it correctly or not using it at all. I just want to see a list of tips how can you properly use ngOnDestroy and what should we do in the best scenario to prevent memory…
2
votes
2 answers

OnChanges does not trigger on partial object change

I am having issues while triggerin Angular(6)'s onChanges life cycle hooks. While emitting parameters from a compontent to a directive I want to hook on the changes. The trigger works perfectly on one-dimensional variables, while objects are not…
2
votes
2 answers

Trigger one component method after other component fully load

I have two components, both are loading in my like this: and index.html Is there a way to…
esquarial
  • 237
  • 4
  • 14
2
votes
2 answers

How to get real attr values in didReceiveAttrs hook, if it's a mutable cell

Please see below sample code. Given I have a component my-text-box my-text-box.hbs {{my-text-box value=modelName}} I want to observe the changes of value property via didReceiveAttrs hook instead of observers for better…
shijistar
  • 101
  • 4
1
vote
1 answer

Vue lifecycle hook race condition

I have a question regarding the Vue lifecycle hooks. I have some method that I want to call first in a hook, but another method is calling before. The desired method is loadData() that calls from beforeMount. This method is responsible for API…
Evgeny
  • 163
  • 1
  • 10
1
vote
1 answer

Why get undefined after the render of the DOM in the following case?

It's a demo in the article 11 Vue.js Lifecycle Hooks I am confused why I can not get the DOM in mounted after 3 seconds, while can get the result as respected if console.log immediately.
Zia
  • 21
  • 3
1
vote
2 answers

Running scripts using lifecycle hook does not work properly in kubernetes

I am new to kubernetes. And I am learning kubernetes using minikube. I have a situation where I have to configure fdw (foreign table concept) in PostgreSQL. I am trying to implement this fdw concept in kubernetes. For that I have two pods meta pod…
1
vote
1 answer

Vuejs: call created() hook twice

I created a hook to reload my data from the database on a button click: