본문 바로가기

IT

[Angular] index.html, app-root, ngModule

@angular

-SPA(Single Page Application)

             -index.html (in default)


@what is the app-root in index.html

-실제로 index.html를 크롬에서 보면 에디터에서 보이지않던 코드가 마지막부분에 추가되어져 있다.

 이건 ts가 컴파일되면서 main.ts에 있는 컴포넌트 정보등을 추가한것으로 main.ts를보면 appModule정보를 참조한다.

 그 appModule를 보면 안에서 appComponent를 정의, 선언하고 있다.(declarations) 

 그리고 appComponent안을 보면 컴포넌트의 selector 즉 선택자가 app-root로 되어져 있다.


@간단하게 설명해보자면, index.html의 app-root는 다음과 같은 경로로 참조되어진다.

index.html -> appModule -> appComponent -> selector in appComponent


@ngModule

app.module.ts안의 ngModule안에 명시하시 않은 컴포넌트는 없는것과 같다. 

결국 ngModule안의 정보만을 가지고 표현하는 구조.

'IT' 카테고리의 다른 글

[angular] href VS routerlink  (0) 2018.03.18
[angular] Router  (0) 2018.03.18
[WEB] `와 '의 차이  (0) 2018.03.16
[Angular] How to add bootStrap in Angular App  (0) 2018.02.18
[Angular] angular, databinding  (0) 2018.02.18