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

setter and getter for Angular

In angular, there is a built in action dialog framework which I've to use to display the action pop up window when showDialog = true. The action dialog will be shown when showDialog=true, else the action dialog will hide when showDialog=false Have…
noob
  • 45
  • 3
  • 11
1
vote
0 answers

Cannot get consistent element Height inside ngAfterViewInit

I have an ion-row inside an ion-grid, and the elements inside the ion-row are displayed dynamically following some conditions. My objective is to retrieve the height of the ion-row once all the conditions are computed and the final view is…
Strider
  • 3,539
  • 5
  • 32
  • 60
1
vote
0 answers

Lifecycle hook after view is rerendered when property changes

I have a component (callout bubble), that needs to calculate it's position based on its native element size. By default it is hidden and thus the element has no size. When I change hidden binding to false, where do I hook for an event, where I can…
Liero
  • 25,216
  • 29
  • 151
  • 297
1
vote
0 answers

Correctly implement ng-content presence when used within ng-if

Current code works but is surely far from ideal (I mean probably not the Angular way). My component may or may not project external content. The div wrapper where the projected content will land is rendered only when one of the component's Inputs is…
Stphane
  • 3,368
  • 5
  • 32
  • 47
1
vote
2 answers

Directive doesn't trigger when input changes

I'm implementing a directive that takes a language (or a set of languages) as input and adds a class to the DOM element where the directive was added. @Directive({ selector: '[appRtlView]' }) export class RTLViewDirective implements OnInit,…
saglamcem
  • 677
  • 1
  • 8
  • 15
1
vote
2 answers

Angular 2 - detect when a bonded property receives a value

I would like how to know when a bonded property receives a value, even if it's the same value. For example That is a feature component import { Component, OnInit, Input, OnChanges, SimpleChanges } from…
rplaurindo
  • 1,277
  • 14
  • 23
1
vote
1 answer

Angular 7: ChangeDetectorRef detectChanges() causes infinite loop when called from inside a subscription

I am posting here after reading all the material related to change detection and similar post and failing to solve my problem. ChangeDetectorRef detectChanges() causes infinite loop when called from inside a subscription. If I don't call…
Ravinder Payal
  • 2,884
  • 31
  • 40
1
vote
2 answers

how to create "ngOnActive" life cycle hook in angular?

I want a life cycle hook to be called when ever my component is active on the main page. its login page. when ever my component is on the main page i.e is active i want to see if i already have login token from previous login and depending on the…
Rahul
  • 975
  • 9
  • 25
1
vote
0 answers

Understanding angular's lifecycle hooks and template with nested for loops

Been working on figuring out an issue I've run into working on some existing code. It's a component with a selector in the HTML that looks like this:
and a template with this structure…
DA.
  • 39,848
  • 49
  • 150
  • 213
1
vote
2 answers

Get the url param from nested component

I develop a MEAN stack application and for the Front-End I use Angular. In angular, I use a navbar and a sidenav bar which are the framework of my layout. Then the routes are displayed in the mat-sidenav-content -> ng-content here: FRAMEWORK…
PierBJX
  • 2,093
  • 5
  • 19
  • 50
0
votes
1 answer

Why does @NgOnChanges not trigger when updating @Input() property from the child itself

@Input() animal = "Tiger" editAnimal(animal: string){ this.animal = animal } The editAnimal function runs when a user types a new animal into a text field and presses a button to submit. Everything works as expected, but the ngOnChanges…
User9123
  • 675
  • 1
  • 8
  • 20
0
votes
1 answer

How trigger component creation even if hidden

Using Angular, my page has multiples components included in NgbNav. Basically, When each component loads, it calls an API and displays a list. The component also emit an event, telling the parent component how much data was found. I use this…
Jean
  • 1,707
  • 3
  • 24
  • 43
0
votes
1 answer

In which order of components is an Angular App instantiated/created?

When generating a basic angular app via ng-cli and creating our own component, which results in a project structure similar to the list below (leaving out all the other clutter for now). The bootstrap order is not changed so we bootstrap app.module…
0
votes
1 answer

How can I access data inside ngOnInit in Angular?

I am using subscribe to get data inside ngOnInit. I want to do some operation based on the value received from it. But when I am trying to access it in ngOnInit, it is undefined. My class : export class UserPropertiesTO { verifierRoles: string[]; …
0
votes
0 answers

Where do I declare my Angular typed form when the labels depend on properties initialised in the constructor?

I have recently migrated to Angular 14 and I am trying to initialise a Typed Form following this guide. It is advising to declare the form directly in the class like so: @Component({ selector: 'login', templateUrl: './login.component.html', …
Ems
  • 67
  • 3