Passing a parameter to ngOnChanges?

1.1k Views Asked by At

I have an ngOnChanges that used SimpleChanges

ngOnChanges(changes: SimpleChanges): void {
    for (const propName in changes) {
      if (changes.hasOwnProperty(propName)) {
        console.log(propName);
        switch (propName) {
          case 'generatedFunctionString':
            this.setTooltipString();
        }
      }
    }
  }

But in the html I would like to make use of that function like this

<textarea title="Function String"
        [(ngModel)]="generatedFunctionString"
        [placeholder]="FUNCTION_DISPLAY_PLACEHOLDER"
        (keyup)="ngOnChanges()">
</textarea>

Is there anyway I could pass the parameters to that method? Thank you.

1

There are 1 best solutions below

0
On

You can pass parameter to ngOnChanges method as an object.

(keyup)="ngOnChanges({generatedFunctionString: generatedFunctionString})"