2

I understand that if I set ngZone to 'noop' in the main.ts file, I'll have to manually detect changes in the component. How do I manually detect changes in this case? I want to update my formDataIncome value to change the data in a graph (which works fine). It's just the interpolation that isn't working.

Thanks in advance!

My component:

import { Component, OnInit, ChangeDetectionStrategy, ElementRef, ChangeDetectorRef } from '@angular/core';

@Component({
  selector: 'app-calculator',
  templateUrl: './calculator.component.html',
  styleUrls: ['./calculator.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})

export class CalculatorComponent implements OnInit {

  formDataIncome: number;

  constructor(private el: ElementRef, private cd: ChangeDetectorRef) { 

    this.formDataIncome = 100000;
  }

  ngOnInit() {
     console.log(this.formDataIncome)
  }
}
Lucho
  • 1,455
  • 1
  • 13
  • 25
MacD
  • 566
  • 3
  • 9
  • 27
  • Hi! Can you clarify your question as the interpolation against the component properties occurs against double brackets in the HTML and the manual change detection in the component can be achieved by using [detectChanges()](https://angular.io/api/core/ChangeDetectorRef#detectchanges) on your ChangeDetectionRef property – Lucho Jan 17 '20 at 19:02

0 Answers0