I have created the following StackBlitz
https://stackblitz.com/edit/angular-ivy-zdknmx?file=src/app/app.component.ts
Basically I have a simply component
@Component({
selector: 'foo-component',
template: `
<p>{{ databearer.content }} {{databearer.index}}</p>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class FooComponent implements OnChanges {
@Input() databearer: any;
ngOnChanges(changes: SimpleChanges): void {
console.info(changes);
}
}
Which I have added one in normal way, and another one dynamically. The one which I have added in normal way the one-way-binding works as expected. But the one which I have added dynamically the one-way-binding does not work.
I'm wondering whether I have done something wrong, or perhaps one-way-binding does not work for dynamically created components in Angular 14?
changeDetection: ChangeDetectionStrategy.OnPush,otherwise Angular wouldn't detect changes. I could remove this to opt for the default strategy. But I'm thinking long term it is better to update this way instead.