hierarhy : app.component> intro.component> header.component에 구성 요소가 있습니다. app.component에 정의 된 header.component에서 사용하려고합니다. @viewChild를 사용하는 방법이 있다는 것을 알고 있습니다. 작동시키는 가장 쉬운 방법은 무엇입니까?angular2 다른 구성 요소의 방법 사용
// 편집 header.component.html에있는 html 태그에 이벤트 (클릭)를하고 싶습니다. 이 함수에서는 app.component에서 메소드를 실행하려고합니다.
당신은 올바른 방향이다. @ViewChild 데코레이터를 사용해야합니다. –
app.component에서 '초기화 됨'메서드는 무엇을 의미합니까? header.component의 app.component에 정의 된 메소드를 호출하는 방법에 대해 묻는 중입니까? 아니면 app.component에서 초기화 된 '속성'이 header.component에 전달되는 것입니까? – amal
나는 그 방법이 정의되었다는 것을 의미했다. 업데이트 된 게시물, 감사합니다 –