Questions tagged [angular-lifecycle-hooks]

A component in Angular has a life-cycle, a number of different phases it goes through from birth to death. We can hook into those different phases to get some pretty fine grained control of our application.

To do this we add some specific methods to our component class which get called during each of these life-cycle phases, we call those methods hooks.

Reference

143 questions
0
votes
0 answers

Does it possible to run ngAfterViewInit again?

I want to re-call my ngAfterViewInit since it is responsible for changing my dom's style. So if my components data changes my component gets updated but my styles are not applying on the new data. Here in the below code my component which is…
sahil aktar
  • 101
  • 10
0
votes
2 answers

Angular set variable after View Init

Situation: Currently I have two tabs on my site, both containing a text. The text has a fixed height and the content-overflow is not shown (overflow: hidden). Problem: I would like to add three dots (icon) if my text is overflowing. To detect if…
Lars
  • 43
  • 5
0
votes
1 answer

Angular directive query sibling HTML

Using Angular 10 I want to query a sibling element. Essentially I have something like this:
0
votes
3 answers

jquery not finding items when routing in Angular

I have the following code inside my angular component that is run inside ngOnInit(): animateMobileSkillBar() : void { console.log("Animation skillbar out"); $( document ).ready(function() { console.log("Animation skillbar inside…
J Agustin Barrachina
  • 3,501
  • 1
  • 32
  • 52
0
votes
1 answer

ngOnchanges and DoCheck in angular

When study the difference between ngOnChanges and DoCheck in Angular, I see something I cant explain and need your help. Basically, I understand that ngOnChanges can't recognize the change of array or object and DoCheck can. I created the stackblitz…
Tony
  • 1,106
  • 1
  • 10
  • 17
0
votes
1 answer

Show updated data that has been retrieved from http call Angular

I am pushing data from a data response that contains a nested array into an array of static data in my component. Programmatically the data is being pushed into the object properly. I saw this while walking through the method and saw my for loop is…
NVA
  • 1,662
  • 5
  • 17
  • 24
0
votes
1 answer

ngOnChanges is not called but the view is updated correctly

I have a question related to the following code: Child export class ChildComponent implements OnChanges { public @Input() data: string[]; ngOnChanges(changes: SimpleChanges) { console.log('I am here'); } } Child Template {{…
0
votes
1 answer

Angular child component not initialised when parent is function during parent oninit

I having a problem showing my alert when triggered in ResetPasswordComponent oninit. The subscribe block for AlertService is not being triggered however if I move the code from oninit to the constructor it will work. However it does not seem like…
John
  • 411
  • 2
  • 8
  • 22
0
votes
1 answer

How to run function after a component became visible in Angular 8?

I want to load datas only if the user see the specific component which load the datas. So don't load before the component is visible. I have this template:
netdjw
  • 5,419
  • 21
  • 88
  • 162
0
votes
1 answer

Is there a Lifecycle hook in angular 8 that is called when an elements button is clicked

I have a main component that contains two nested components, one of the components contains input fields(2) and a button to add an item, the other sibling component displays the items in a loop. I have a service that picks the values from the…
briancollins081
  • 845
  • 9
  • 19
0
votes
1 answer

Angular ngOnChanges not called after ngOnDestroy of parent

I have a child component which accepts an input In the child component, I detect changes to the customModel input by doing: @Input() customModel: CustomModel; ngOnChanges(changes:…
0
votes
2 answers

ngDoCheck VS using function as attribute value - Performace difference

I have an anchor tag in the web page whose href value depends on a service whose properties are not under control of this component. The service details are populated asynchronously. To get the service details and create the href value, I thought of…
Ravi Sankar Rao
  • 1,050
  • 11
  • 26
0
votes
0 answers

Angular life-cycle sequence between parents and child components

I have onInit on parent that does massaging of data that will be the input of child component. And the input is used in child’s onInit to be passed to a service. It is working fine when I put break point on child’s onInit, the input is already…
Chikakow
  • 29
  • 6
0
votes
0 answers

Angular 6 app Component and child components Execution

I'm developing an application using Angular 6 and I'm looking for some help/guidance on this. Below is my app component. app.component.html --header-- -- router outlet-- --footer-- And I'm invoking two observable http services to get the data in…
S.Siva
  • 1,901
  • 4
  • 17
  • 22
0
votes
0 answers

Why does angular life cycle hooks look Synchronous

I have a component with some lifecycle hooks. By synchronous I mean the execution of hooks one after another. export class MyComponent implements OnInit, OnChanges, AfterContentInit, AfterViewInit { ngOnInit() { console.log('ngOnInit'); …
prabhatojha
  • 1,925
  • 17
  • 30