0
내가 업데이트 된 값을 감지하지 못하는 템플릿 내가 MyComponent
을 테스트하고 comp.ngOnInit()
을 수행 할 때 SubComponent
트리거 변경 감지
를 MyComponent이
@Component({
selector: 'my-component',
template: `
<sub-component [input]="property"></sub-component>
`
})
export class MyComponent implements OnInit {
property: string;
constructor() { }
ngOnInit() {
this.property = 'value passed to sub component';
}
}
과 같은 포함입니다 MyComponent
, SubComponent
을 테스트입니다 가정 해 보겠습니다 input
입니다.
어떻게 SubComponent
에서 변경 사항을 감지 할 수 있습니까?
이렇게해도 작동합니까? 나는'@ Input' 주석을 보지 못했고, 여러분의 자녀에게 잘못된 속성 이름 ('property')을 사용하고 있습니다. – Alex