Итак, мой вопрос здесь, будет ли проверка представления триггера источника событий? (Обнаружение изменений).
Спасибо!
родительский компонент
@Component({
selector: 'app-root',
template: '<app-child1 [person]="person", (changOnPerson)="onPersonChange($event)">',
})
export class AppComponent {
person: Person = {
name: 'Alex',
age: 20
};
constructor() {
}
onPersonChange($event) {
this.person = $event.change;
}
}
child1.compnent
@Component({
selector: 'app-child1',
template: '{{person | json}}',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class Child1Component implements onInit {
@Input() person: Person;
@Output() changOnPerson = new EventEmitter();
constructor() { }
ngOnInit() {
setTimeout(() => {
this.person.name += ' ,abc';
// core code here !
this.changOnPerson.emit({ change: this.person });
}, 2000);
}
}