Using [(ngModel)] in my child component with a string passed from the parent via @Input() is causing some issues.
Although the string is successfully passed from the parent to the child, any changes made to it within the child component do not reflect back to the parent's value.
I am confused about what might be missing or causing this problem.
Parent Component:
@Component({
selector: 'my-app',
template: `
<div>
<child [(value)]="name"></child>
<p>{{name}}</p>
</div>
`,
})
export class App {
name:string = 'MyValue';
constructor() {
}
}
Child Component:
import {Component, Input} from '@angular/core'
@Component({
selector: 'child',
template: `
<div>
<p>My custom input</p>
<textarea [(ngModel)]="value"></textarea>
</div>
`,
})
export class Child {
@Input() value:string;
constructor() {
}
}
A Plnkr example demonstrating the issue can be found here: https://plnkr.co/edit/jCF5kt73P38EFYUAZF6l