I am creating some kind of auto word correction module in Angular2.
I have an EventEmitter setup in my child component
import {Component, Input, Output, EventEmitter} from '@angular/core';
...
export class StudyThumbsComponent{
@Output() notify: EventEmitter<any> = new EventEmitter();
...
verify(input, i) {
this.answer.input = input;
this.answer.id = i;
this.notify.emit(this.answer);
}
}
"i" is the input's index as there are many inputs to check within the component.
The child component html:
<input type="text" [(ngModel)]="item.input" (keyup)="verify($event, i)">
The logic for auto word correction is in the parent component since there could be different types of child components requiring the auto word correction feature:
export class ParentComponent{
verify(event:any, i) {
var answer = event.target.value;
// the variable answer gets corrected/modified and assigned to...
var correctedAnswer;
}
onNotify(answer) {
this.verify(answer.input, answer.id);
}
}
This posted code works ups to that point, so the question is, how do I update the child's component input with the corrected answer (correctedAnswer) ?