Angular -[component중심의 개발]

박성원·2020년 12월 1일
0

Angular

목록 보기
3/11
post-thumbnail

새로운 컴포넌트 생성 방법

터미널의 실행 후
ng g compoenent my

새로운 컴포넌트가 하위에 생겼다.

자식 컴포넌트 (my.component.html)

<p>my works!</p>

부모 컴포넌트 (app.component.html)

<h1>자식 컴포넌트 포함</h1>
다음과 같이 자식 컴포넌트 selector를 지정하면, 자동으로 자식 컴포넌트 template이
삽입된다.
<hr />
<app-my></app-my>

이처럼 자식이 생성되면, 자식 selector를 호출하여 부모에서 사용할 수 있다.

profile
개발 일기장

0개의 댓글