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

Angular 6 subscribe Event on constructor called multiple times

In my component on constructor (Child Component) I add simple event This is my code: this._modalService.onHidden.subscribe( result => { console.log("_modalService.onHidden"); if(this.shown){ this.shown = false; …
24sharon
  • 1,859
  • 7
  • 40
  • 65
0
votes
1 answer

What to do to run a function just after After ngoninit in angular 5

This is about lifecycle hooks. My requirement is to run a function is the background just after initialization of the page. i have used ngAfterViewInit(). but its not waiting for the array which is found from the ngoninit(). export class…
Abhiz
  • 970
  • 1
  • 16
  • 36
0
votes
1 answer

Angular - Behavior of shared service subscribe

Using Angular I have a service to share some variable from different components. Like this: import { Injectable } from "@angular/core"; import { BehaviorSubject } from "rxjs"; @Injectable() @Injectable({ providedIn: "root" }) /** * Service to…
PierBJX
  • 2,093
  • 5
  • 19
  • 50
-1
votes
1 answer

Inject a fetched value from the url in a child component Angular

I'm trying to inject a value from an the Url that I want to inject in a child component. I'm able to get the param from the url and update my DOM with a property but the same property doesn't behave the same way when I inject it in a child…
-1
votes
1 answer

When gets a service destroyed that was injected into a dialog?

I wrote a service and injected it into my dialog. I expected the service's ngOnDestroy() function to be called when I close the dialog. But it doesn't. So I wondering when ngOnDestroy() will be fired? How would I unsubscribe my Subscriptions in the…
coconut
  • 494
  • 2
  • 5
  • 13
-3
votes
1 answer

Angular - React to content rendered after Navigation

I have an angular application with several different components and pages that display user-created html-content. After the content is completely loaded, i need to search it for specific elements and add an onclick-event to them. So my idea was to…
Heady
  • 935
  • 3
  • 10
  • 23
1 2 3
9
10