None
None

Reputation: 9247

CurrentValue is changed but ngOnChanges is not firing?

ngOnChanges(changes: SimpleChanges) {
    setTimeout(() => {
        console.log(changes.output,'adjaslćjkdajklsdajslk');
    }, 1000)


        this.confing = changes.output.currentValue;
        console.log(changes.output.currentValue,'aaaaaaaaaa');
        // You can also use categoryId.previousValue and 
        // categoryId.firstChange for comparing old and new values
        if(this.output['user-activities']){
            this.confing = this.output['user-activities'];
        }

    }

I change value and it is in changes.output.currentValue but it not firing it.Any suggestion?

EDIT:

In ordervriewcomponent i have this:

 getFlowTab(ordNum?: any, processCode?: any) {
        let path: string = '/uomback/workflowexecutionplan/user-activities';
        this.restService.get(path, { ordnum: ordNum, processCode: processCode }).subscribe(response => {
            this.output['user-activities'] = response['payload'];
            console.log(this.output,'u order overview');
        })
    }

and OnChanges im calling in flowtab component. When i do console.log(changes) first time nothing but when i populate output and go on that object i find that currentValue is changed but its not fired

Upvotes: 1

Views: 2022

Answers (2)

Sheik Althaf
Sheik Althaf

Reputation: 1605

ngOnChanges only trigger when @Input value changes.

if your currentValue is a input element then go with ReactiveFormModule and create a form and then subscribe

this.currentValue.valueChanges.subscribe(() => {
  // get notified when the value changes
});

Upvotes: 2

Raed Khalaf
Raed Khalaf

Reputation: 2065

ngOnChanges is triggered by angular when the @Input variables is changed only from the parent component.

if you changed the input variables from the same component it will not be triggered.

Upvotes: 1

Related Questions