I have a component with this code inside:
<div class="form-group">
<label for="title">Title</label>
<input type="text" [(ngModel)]="model.title" name="title" required/>
</div>
I am trying to migrate the whole thing into another component, input-component:
@Component({
selector: 'input-component',
template: `
<div class="form-group">
<label for="title">Title</label>
<input type="text" [(ngModel)]="value" name="title" required/>
</div>
`
})
export class InputComponent {
@Input() value: string;
}
So the first example code will be replaced with:
<input-component [value]="model.title"></input-component>
When model.title is changed, the value inside the HTML element is changed, however when I change the contents of the element, model.title does not change.
How can I achieve two-way data binding with this setup?