It seems like there's a piece I might be overlooking, but here's my current situation - I have data that is being linked to the ngModel input of a component, like so:
Typescript:
SomeData = {
SomeValue: 'bar'
}
Snippet from the view template:
<foo [(ngModel)]="SomeData.SomeValue"></foo>
Component:
import { Component, OnChanges, SimpleChanges } from '@angular/core';
@Component({
selector: 'foo',
template: `<input type="text" [ngModel]="value" (ngModelChange)="modelChange($event)
(change)="elementChange($event)"/>`
})
export class FooComponent {
ngOnChanges(changes: SimpleChanges) {
// Triggered when @Input members change
}
modelChange(value) {
// Triggered when a change in the HTML element will update the model, not when the model changes elsewhere
}
elementChange(event) {
// Triggered when the value of the HTML element changes
}
}
Based on my comments in the example, I can detect Input changes, when the HTML element's value will change the model, and when the HTML element's value changes.
I want to be able to determine from within the component when the property assigned to ngModel in the view template (i.e. SomeData.SomeValue) changes. Angular handles this internally to update the value in the HTML, but I'm unsure of how to intercept and respond to this change within the component itself for additional actions.