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
1 answer

Creating an directive to spy angular life cycle hooks

Is there anyway to make a directive to detect every life cycle hooks like ngOnDestroy() and implements some garbage collector before the component get destroyed ? I want to do this to avoid the component to let something run and cause memory leak
Gabriel Guedes
  • 481
  • 5
  • 15
0
votes
1 answer

Are Angular lifecycle hooks called on every component of a nested component structure?

This is just a conceptual question. I am trying to learn more about how Angular lifecycle hooks work. My question is, if I have a nested component structure like below:
0
votes
1 answer

How to stop multi trigger of functions in angular when using functions in template?

I am using a function inside HTML template, I cannot use a variable directly because the condition is little complex. My Problem is that the function in the template is called multiple times. For Example this Stackblitz (Minimal, Reproducible…
dota2pro
  • 7,220
  • 7
  • 44
  • 79
0
votes
0 answers

Can angular directive listen to hosts lifecycle hooks?

I want to create an angular directive that will be able to be on any host component and will make the host component background blink with green when the host's ngOnChange fires. I have tried to get access(in the directive) to the hosts ngOnChange…
0
votes
1 answer

Nativescript Angular Lifecycle hooks not applying css classes to dynamic components

When components are added dynamically to a page, style information that inherits from classes do not render in the final component We have monitored that all lifecycle hooks are correctly executing, and shown that the classes are appended to the…
0
votes
1 answer

Problem closing my matDialog in my function ngDoCheck() Angular

I have a problem closing my matDialog of Angular Material in my ngDoCheck() function. EDIT : StackBlitz HERE Explanation : On my main page, I have a button that opens a matDialog to extract or not data into an Excel file. In my matDialog, I have two…
0
votes
0 answers

ExpressionChangedAfterItHasBeenCheckedError when trying to set the last active MatTab?

I have an Auth component. This component uses the mat-tab-group component which has two mat-tab components that allow you to easily go back and fourth between login and sign up. Login is at index 0 (the first displayed form) sign up is at index 1…
O.MeeKoh
  • 1,976
  • 3
  • 24
  • 53
0
votes
2 answers

Execute a Typescript function according to a scenario in Angular

In my application, I have two comboboxes in a component. Their default values ​​are both null. When selecting a period or a user, the value is sent to the store. This allows you to use the period and the selected user in different…
Quentin
  • 1,865
  • 2
  • 24
  • 40
0
votes
1 answer

Angular ngOnInit never executed when creating component inside ngFor

I ran into a mystery. I'm in an ngFor loop like in this example:
Only for…
Hivaga
  • 3,738
  • 4
  • 23
  • 36
0
votes
0 answers

Angular 7 - ngOnInit is not getting called

We do have a main angular app that references library representing sub-area of a main app. We wanted to have ability of defining separated routes in our library. Eg: app has root paths: /app library has child paths: /library After going to route…
Patryk
  • 3,042
  • 11
  • 41
  • 83
0
votes
0 answers

How to identify that *ngFor loop has finished changes in markup?

I have an array of companies getting from a service and binding that array data with the help of *ngFor directive. Now, I want to show a whole page covered 'waiting..' till the data gets bind to the mark up. Till the time, I tried…
musigh
  • 167
  • 1
  • 3
  • 13
0
votes
0 answers

ExpressionChangedAfterItHasBeenCheckedError Angular7

I have this error at runtime i tried a few things but none seem to work. the problem occurs because of this
KLTR
  • 1,263
  • 2
  • 14
  • 37
0
votes
0 answers

"ExpressionChangedAfterItHasBeenCheckedError"; I don't understand what type of operations which are inside the lifecycle hooks, make it to be thrown

It's important to me due to certain reasons, to understand how Angular works; well; One thing that I can't understand, is the error that's mentioned in the title, and what things I'm prohibited by Angular to do inside the lifecycle hooks (if there…
0
votes
1 answer

Call ngAfterViewInit of Angular component from common place

I am using bootstrap tooltip. I want to trigger ngAfterViewInit for every component from some common place. Common place(like app.module.ts) ngAfterViewInit() { $('[data-toggle="tooltip"]').tooltip(); } Component_1: There is no…
0
votes
1 answer

How to re-instantiate/destory a component in Angular-6

Can you check the existence of an instance of a component from the component itself ? Can you destroy existing instance and create a new instance ? I seem to have a problem with one of my components. When visited multiple times consecutively with…
user2533922
  • 85
  • 1
  • 14
1 2 3
9
10