I have the following code in my child component:
- Component
@Input() query: string;
ngOnChanges(changes) {
if (changes['query']) {
console.log('query is now: ', this.query);
}
}
- Template
<input type="text" [(ngModel)]="query">
Then in my parent component I have the following: 1. Template
<my-input
(onSearch)="searchSelected($event)"
[searchTerm]="selectedSearch">
</my-input>
<span>search is: {{selectedSearch}}</span>
My problem is whenever I type in my-input component it never updates selectedSearch in the parent. Also, when I set selectedSearch in the parent component it does not get updated on the child (ngOnChanges does not trigger also). What am I doing wrong?