Say I have this setup:
template:
<input [(ngModel)]="myValue" type="text" />
<button (click)="addText">Click me</button>
{{myValue}}
code:
addtext()
{
this.myValue='test';
}
If I click the button the inputfield stays empty, but the {{myValue}} is updated. How can I add the text to the inputfield (or better update it, since the nGModel has the real value already)?
Edit:
When clicking the button a child component is shown where the user adds/selects some data. When the child is filled, an event is emitted with the data of the child component. The parent reacts via an "onFilled"-event and changes the model. But since the View doesnt know about the changes, the input is not updated (even the ng-reflect-model is correct).
So my real question is: How to force angular to run an update on the view / rerender it?
Emit-Part:
Child:
@Output myEmitter:new EventEmitter<object>();
filled(){
this.myEmitter.emit({value:'Test'});
}
Parent: (myEmitter)='onMyEmitter($event)' added to input
onMyEmitter(value) {this.myValue = value}