Привет, в чем разница между внедрением родительского компонента в дочерний компонент и использованием декоратора @Input ()?Есть ли разница в производительности?
PARENT
@Component({
selector: 'a-comp',
template: `<b-comp [text]="text"></b-comp>`
})
export class AppComponent{
public text = 'some Text';
}
Child
@Component({
selector: 'b-comp',
template: `<span>{{ text }}</span>`
})
export class BComponent {
@Input() text;
constructor() {}
}
PARENT
@Component({
selector: 'a-comp',
template: `<b-comp ></b-comp>`
})
export class AppComponentt {
public text = 'some Text';
}
Ребенок
@Component({
selector: 'b-comp',
template: `<span>{{ text }}</span>`
})
export class BComponentt {
public text = this.parent.text;
constructor(private parent: AppComponent) {}
}