Questions tagged [ngonchanges]

Respond when Angular (re)sets data-bound input properties. The method receives a SimpleChanges object of current and previous property values. Called before ngOnInit and whenever one or more data-bound input properties change.

123 questions
0
votes
2 answers

Angular fire OnChanges to dynamic child by typescript (NO HTML)

I'm creating my component by Typescript and passing from there my inputs to my child. parent TS this.childComponent = this.viewContainerRef.createComponent(this.data.body).instance; this.childComponent['childInput'] = 5; child TS @Input()…
Python
  • 31
  • 6
0
votes
1 answer

How to fix Angular Error: NG0100 before ngOnChange is called

There are 2 child-components (bar/edit) under app-component, edit component will emit an @output number from ngOnChanges function to the app component . Which the app component will stored it like…
AkiZukiLenn
  • 337
  • 3
  • 14
0
votes
1 answer

Inside ngOnChange, SimpleChange currentValue is defined but console log saids undefined

Inside the typescript, there are a name variable takes input from another component. @Input() name : any ; And inside the ngOnChange I print the SimpleChange object like this. ngOnChanges(changes: SimpleChange){ console.log(changes); …
AkiZukiLenn
  • 337
  • 3
  • 14
0
votes
0 answers

why angular ngOnchange is only triggering once?

I have an app-file-actionscomponent which emit topropertyEvent if dialog res is true then app-general-details component which has an output and then app-general-details is rendered by the parent component which is app-main-details and then on…
Diya Agastya
  • 59
  • 1
  • 8
0
votes
1 answer

Angular update @Input() Object

I've got a GameStats Object of my self defined interface. If I change the value of a attribute the child component doesn't recognize it. I found solutions with ngOnChanges which doesn't get fired, and with ngDoCheck which still contains the old…
user17087006
0
votes
3 answers

OnChanges won't detect the changes

I am creating a simple app. And I pass an array to the child component. When I remove an item from the array, ngOnChanges won't detect the changes unless I refresh the page. I can log the changes only once at the first page load but not when the…
0
votes
2 answers

ngOnChanges only works when it's not the same value

So basically I have a modal component with an input field that tells it which modal should be opened (coz I didn't want to make a component for each modal): @Input() type!:string ngOnChanges(changes: SimpleChanges): void { this.type =…
santocielo99
  • 83
  • 3
  • 14
0
votes
0 answers

How to use any type of property in a component on ngOnchanges

How to use any type of property in a component on ngOnchanges without @input property. I can not use Rxjs for this situation. It is not a child component so i have no @input property. Please see the following example. import { Component, OnInit,…
0
votes
0 answers

ngOnchanges is triggered and geting the currentValue(it is an object) but can't access the value inside the object

dragAndUpload.ts export class DragAndUploadComponent implements OnInit { @Input() filesData: any; ngOnChanges(changes: SimpleChanges): void { console.log(changes.filesData.currentValue); …
0
votes
1 answer

Angular ngOnchanges calls method, but method does not call service or output results

I am confused by what is happening in a section of my app. I have a component that uses ngOnChanges. ngOnchanges fires right before ngOnInit when the component loads. Both ngOnChanges and ngOnInit call a certain method (fetchResults) that calls…
mo_maat
  • 2,110
  • 12
  • 44
  • 72
0
votes
1 answer

Why can you access angular ngOnChanges SimpleChange property directly from SimpleChange object without using index

I am using ngOnChanges and I've set the SimpleChange parameter as below. Why is it that I can directly access my input property using changes.currentValue without having to get the property using indexing? Both work and I'm confused as to why? …
mo_maat
  • 2,110
  • 12
  • 44
  • 72
0
votes
0 answers

set lat long dynamically for google map and add marker: angular 12

I am using google map in angular project (ngx-google-places-autocomplete and angular/google-maps). Functionality is like user can select location and its latitude and longitude gets store. Now depending on lat, long stored, I need to display google…
0
votes
0 answers

Pass data from parent component to child component in angular

I have 2 components. I want to pass data from parent component to child component & generate the child html based on a drop down option selection in parent component. This is my parent component html