SlideShare a Scribd company logo
NgModule
by peter yun
Concept
- To organize the application
- To consolidate components, directives, services and
pipes
- To be lazy loaded async by the router
Concept
Module block Module block Module block
Big Module block
Module block Module block Module block
Big Module block
App Module block
Module Block 종류
- 기능: Feature
Formatter, Utils, State 실제 수행 단위 블럭
- 계층: Layer
VDK, Common, Portal 의존관계 논리적인 블럭
- 애플리케이션: Domain
기능 + 계층 블럭을 사용하는 블럭
NgModule Metadata
- component, directive, pipe 선언하기 (declare)
- 다른 컴포넌트에서 사용할 수 있도록 public 으로 만들기
- 구현 상세내역은 숨길 수 있음
- 다른 모듈 import 해서 component, directive, pipe 사용
하기
- service provide 를 애플리케이션 레벨로 하기
NgModule 갯수
애플리케이션에서 반드시 하나는 존재해야 한다.
===
Root Module
Root NgModule 만들기
- 파일: app.module.ts
- 데코레이션: @NgModule({ … metadata … })
imports: 의존 관계 모듈
declarations: application의 컴포넌트 tree에 포함되는 컴포넌트들 목록
정의,
기존 컴포넌트에 directives: [...] 넣었던 것을 제거 시켜줌
boostrap: 최초 수행 기동할 컴포넌트
Root NgModule 만들기
- 파일: app.module.ts
JIT Compiler
- Just-In-Time: 브라우져에 보여질 애플리케이션 컴파일
- @angular/platform-browser-dynamic 의
platformBrowserDynamic 이용 -> 기존은 bootstrap
JIT Compiler
- NgModule 에는 Components, Directives, Pipes가 쓰이는
지 정의가 되고, 이를 이용해 NgModule안에 사용하는
Component, Directive의 Template에 대한 컴파일 시점을
결정한다.
- JIT는 브라우져에 보이는 시점이다.
AOT Compiler
- Ahead Of Time Compiler: 미리 템플릿 바인딩을 컴파일함
- @angular/platform-browser 의 platformBrowser 이용
AOT Compiler
- pre-compile 된 static file 을 미리 만들어 놓는다.
- 초기 로딩 성능 향상이 목적
Metadata 형식
- declarations: 모듈안에서 사용하는 Component, Directive, Pipe
- imports : 모듈에서 사용할 다른 모듈 또는 Provider를 가진 모듈 (root injector를 위한 것임)
- exports: 외부로 노출할 Module, Component, Directive, Pipe
- providers: Lazy loaded module이면 Module Injector로 등록, 그외는 Root Injector로 등록
- entryComonents: bootstrap 컴포넌트 또는 lazy loaded될 때 entry component - 자동설정됨
Metadata - imports
- 모듈안에서 사용할 의존 관계의 모듈을 설정한다.
Metadata - imports
Metadata - declarations
- 컴포넌트가 다른 컴포넌트를 템플릿에서 사용할 때 이전방
식은
사용하는 컴포넌트에서 directives: [...] 설정 - deprecated
예정
- NgModule({
declarations: [ AComponent, BDirective, CPipe]
});
Metadata - declarations
- 모듈에 속하는 component, directive, pipe 를 declarations
에 설정 (컴포넌트를 new 한다.)
- 다른 컴포넌트에 directives: [], pipes: [] 설정이 필요없어짐
Metadata - declarations
Metadata - providers
- 전체 애플리케이션에 DI 가능토록 설정 root injector를 통해 해당 서비
스들을 설정한다.
- module level의 injector는 존재하지 않는다.
- 내부에서만 사용하는 서비스는 컴포넌트에 직접 providers 설정해서
사용한다.
- Lazy Loaded Module에 providers는 설정하지 않는다 (routing설정)
Metadata - providers
Metadata - exports
- 의도한 것 만을 보이게 한다.
- 내부에서 사용하는 Directive, Pipe 등을 숨길 수 있다. 즉,
declaration 해서 내부에서 사용하는 Directive, Pipe 들은
private 이 되고, exports 한 것만 외부에서 사용할 수 있다.
- Feature, Layer Module 이 될 수 있다.
Metadata - exports
Metadata - exports
Metadata - bootstrap
- 최초 수행할 컴포넌트
- AppModule 한 곳만 등록한다
Metadata - bootstrap
forRoot(): ModuleWithProviders
- AppModule에만 서비스 Provider를 제공하고 싶을 경우 사용한다.
- NgModule() 내용만 다른 모듈에서 사용가능하고, AppModule에
SharedModule 등록시에 forRoot() 를 호출한다. (전장의 AppModule
참조)
Jamong Layer 별 모듈 구조
VDK Module
Common Module
App Module
PlatformModule
참조
- 공식문서: https://angular.io/docs/ts/latest/guide/ngmodule.html
- 설명문서: https://docs.google.com/document/d/1isijHlib4fnukj-
UxX5X1eWdUar6UkiGKPDFlOuNy1U/pub#h.s0x91qpqpife
- 모듈LifeCycle Hook:
https://docs.google.com/document/d/1SCjDU1037CsAsXWs3tlFXFzhZtmotLw8_gcMrwlXOq
o/edit

More Related Content

PPTX
Angular2를 위한 컴포넌트 분석과 개발
PPTX
Angular2를 활용한 컴포넌트 중심의 개발
PPTX
Angular 2 rc5 조사
PDF
Front end dev 2016 & beyond
PDF
AngularJS 2, version 1 and ReactJS
PDF
안드로이드 플랫폼 설명
PPTX
AngularJS의 개발방식에 대하여
PPTX
Angular2를 위한 타입스크립트
Angular2를 위한 컴포넌트 분석과 개발
Angular2를 활용한 컴포넌트 중심의 개발
Angular 2 rc5 조사
Front end dev 2016 & beyond
AngularJS 2, version 1 and ReactJS
안드로이드 플랫폼 설명
AngularJS의 개발방식에 대하여
Angular2를 위한 타입스크립트

What's hot (20)

PDF
[오픈소스컨설팅]Spring 3.1 Core
PPTX
3.Spring IoC&DI(spring ioc실습, XML기반)
PDF
Universal Rendering
PPTX
GDG DevFest 2017 Seoul 프론트엔드 모던 프레임워크 낱낱히 파헤치기
PDF
Spring Framework - Inversion of Control Container
PPTX
세미나 Spring mybatis
PDF
Tomcat monitoring using_javamelody
PPTX
Maven
PDF
Spring boot 5장 cli
PPTX
스프링프레임워크 & 마이바티스 무.료 강의자료 제공 (Spring IoC & DI)_ 구로자바학원/구로오라클학원/구로IT학원
PDF
Spring boot 공작소(1-4장)
PPTX
메이븐파헤치기(김우용)
PDF
XECon2015 :: [3-2] 오승훈 - XE3 플러그인 제작 소개
PPTX
Spring boot DI
PDF
메이븐 기본 이해
PPTX
Eclipse RCP 2/2
PPTX
NCS기반 Spring Framework & MyBatis_ 스프링프레임워크 & 마이바티스 ☆무료강의자료 제공/ 구로오라클학원, 탑크리에...
PDF
Modern PHP
PDF
(탑크리에듀_스프링/Spring/마이바티스/Mybatis/구로IT실무학원추천)#3.스프링프레임워크 & 마이바티스 (Spring Framew...
[오픈소스컨설팅]Spring 3.1 Core
3.Spring IoC&DI(spring ioc실습, XML기반)
Universal Rendering
GDG DevFest 2017 Seoul 프론트엔드 모던 프레임워크 낱낱히 파헤치기
Spring Framework - Inversion of Control Container
세미나 Spring mybatis
Tomcat monitoring using_javamelody
Maven
Spring boot 5장 cli
스프링프레임워크 & 마이바티스 무.료 강의자료 제공 (Spring IoC & DI)_ 구로자바학원/구로오라클학원/구로IT학원
Spring boot 공작소(1-4장)
메이븐파헤치기(김우용)
XECon2015 :: [3-2] 오승훈 - XE3 플러그인 제작 소개
Spring boot DI
메이븐 기본 이해
Eclipse RCP 2/2
NCS기반 Spring Framework & MyBatis_ 스프링프레임워크 & 마이바티스 ☆무료강의자료 제공/ 구로오라클학원, 탑크리에...
Modern PHP
(탑크리에듀_스프링/Spring/마이바티스/Mybatis/구로IT실무학원추천)#3.스프링프레임워크 & 마이바티스 (Spring Framew...
Ad

Viewers also liked (12)

PPTX
Angular 2 어디까지 왔을까
PPTX
Angular2 가기전 Type script소개
PPTX
What is the meteor?
PDF
Working with npm packages
PPTX
InfiniFlux DURATION
PDF
InfiniFlux with_php
PDF
Tugas web
PDF
PPTX
583: Review of iPhone Applications for Diabetes Self-Management
PPTX
Quantified Self and the Self-tracking Patient (Body Media)
PPT
741: Integrating Open Source Web 2.0 and Smartphone Technologies to Automate ...
PPTX
Issues in Mobile Health (Barbara Mittleman)
Angular 2 어디까지 왔을까
Angular2 가기전 Type script소개
What is the meteor?
Working with npm packages
InfiniFlux DURATION
InfiniFlux with_php
Tugas web
583: Review of iPhone Applications for Diabetes Self-Management
Quantified Self and the Self-tracking Patient (Body Media)
741: Integrating Open Source Web 2.0 and Smartphone Technologies to Automate ...
Issues in Mobile Health (Barbara Mittleman)
Ad

Similar to Angular2 NgModule (20)

PDF
우아한테크세미나-우아한멀티모듈
PDF
Dagger with multi modules
PPT
Component configurator
PDF
LucideWorks Banana 소개
PDF
[1A5]효율적인안드로이드앱개발
PPTX
Vue guide v0.1
PPTX
오픈소스 소프트웨어 성능 최적화 보고서 6장
PPTX
Mirantis open stack deployment automation
PPTX
Spring Boot + React + Gradle in VSCode
PDF
Jpa 쿼리 포함 자료
PDF
Jpa 쿼리 포함 자료
PPTX
K8s beginner 2_advanced_ep02_201904221130_post
PDF
Internship backend
PDF
"Web3 USDT Monitor with Kubernetes & Docker
PDF
Apache module-201511
PPTX
PDF
[2022]Flutter_IO_Extended_Korea_멀티모듈을활용한플러터클린아키텍처_...
PDF
Androidpn guide-0.5.0-ko
PPTX
Application Monitoring 신규 기능 소개 (서영일)
우아한테크세미나-우아한멀티모듈
Dagger with multi modules
Component configurator
LucideWorks Banana 소개
[1A5]효율적인안드로이드앱개발
Vue guide v0.1
오픈소스 소프트웨어 성능 최적화 보고서 6장
Mirantis open stack deployment automation
Spring Boot + React + Gradle in VSCode
Jpa 쿼리 포함 자료
Jpa 쿼리 포함 자료
K8s beginner 2_advanced_ep02_201904221130_post
Internship backend
"Web3 USDT Monitor with Kubernetes & Docker
Apache module-201511
[2022]Flutter_IO_Extended_Korea_멀티모듈을활용한플러터클린아키텍처_...
Androidpn guide-0.5.0-ko
Application Monitoring 신규 기능 소개 (서영일)

Angular2 NgModule

  • 2. Concept - To organize the application - To consolidate components, directives, services and pipes - To be lazy loaded async by the router
  • 3. Concept Module block Module block Module block Big Module block Module block Module block Module block Big Module block App Module block
  • 4. Module Block 종류 - 기능: Feature Formatter, Utils, State 실제 수행 단위 블럭 - 계층: Layer VDK, Common, Portal 의존관계 논리적인 블럭 - 애플리케이션: Domain 기능 + 계층 블럭을 사용하는 블럭
  • 5. NgModule Metadata - component, directive, pipe 선언하기 (declare) - 다른 컴포넌트에서 사용할 수 있도록 public 으로 만들기 - 구현 상세내역은 숨길 수 있음 - 다른 모듈 import 해서 component, directive, pipe 사용 하기 - service provide 를 애플리케이션 레벨로 하기
  • 6. NgModule 갯수 애플리케이션에서 반드시 하나는 존재해야 한다. === Root Module
  • 7. Root NgModule 만들기 - 파일: app.module.ts - 데코레이션: @NgModule({ … metadata … }) imports: 의존 관계 모듈 declarations: application의 컴포넌트 tree에 포함되는 컴포넌트들 목록 정의, 기존 컴포넌트에 directives: [...] 넣었던 것을 제거 시켜줌 boostrap: 최초 수행 기동할 컴포넌트
  • 8. Root NgModule 만들기 - 파일: app.module.ts
  • 9. JIT Compiler - Just-In-Time: 브라우져에 보여질 애플리케이션 컴파일 - @angular/platform-browser-dynamic 의 platformBrowserDynamic 이용 -> 기존은 bootstrap
  • 10. JIT Compiler - NgModule 에는 Components, Directives, Pipes가 쓰이는 지 정의가 되고, 이를 이용해 NgModule안에 사용하는 Component, Directive의 Template에 대한 컴파일 시점을 결정한다. - JIT는 브라우져에 보이는 시점이다.
  • 11. AOT Compiler - Ahead Of Time Compiler: 미리 템플릿 바인딩을 컴파일함 - @angular/platform-browser 의 platformBrowser 이용
  • 12. AOT Compiler - pre-compile 된 static file 을 미리 만들어 놓는다. - 초기 로딩 성능 향상이 목적
  • 13. Metadata 형식 - declarations: 모듈안에서 사용하는 Component, Directive, Pipe - imports : 모듈에서 사용할 다른 모듈 또는 Provider를 가진 모듈 (root injector를 위한 것임) - exports: 외부로 노출할 Module, Component, Directive, Pipe - providers: Lazy loaded module이면 Module Injector로 등록, 그외는 Root Injector로 등록 - entryComonents: bootstrap 컴포넌트 또는 lazy loaded될 때 entry component - 자동설정됨
  • 14. Metadata - imports - 모듈안에서 사용할 의존 관계의 모듈을 설정한다.
  • 16. Metadata - declarations - 컴포넌트가 다른 컴포넌트를 템플릿에서 사용할 때 이전방 식은 사용하는 컴포넌트에서 directives: [...] 설정 - deprecated 예정 - NgModule({ declarations: [ AComponent, BDirective, CPipe] });
  • 17. Metadata - declarations - 모듈에 속하는 component, directive, pipe 를 declarations 에 설정 (컴포넌트를 new 한다.) - 다른 컴포넌트에 directives: [], pipes: [] 설정이 필요없어짐
  • 19. Metadata - providers - 전체 애플리케이션에 DI 가능토록 설정 root injector를 통해 해당 서비 스들을 설정한다. - module level의 injector는 존재하지 않는다. - 내부에서만 사용하는 서비스는 컴포넌트에 직접 providers 설정해서 사용한다. - Lazy Loaded Module에 providers는 설정하지 않는다 (routing설정)
  • 21. Metadata - exports - 의도한 것 만을 보이게 한다. - 내부에서 사용하는 Directive, Pipe 등을 숨길 수 있다. 즉, declaration 해서 내부에서 사용하는 Directive, Pipe 들은 private 이 되고, exports 한 것만 외부에서 사용할 수 있다. - Feature, Layer Module 이 될 수 있다.
  • 24. Metadata - bootstrap - 최초 수행할 컴포넌트 - AppModule 한 곳만 등록한다
  • 26. forRoot(): ModuleWithProviders - AppModule에만 서비스 Provider를 제공하고 싶을 경우 사용한다. - NgModule() 내용만 다른 모듈에서 사용가능하고, AppModule에 SharedModule 등록시에 forRoot() 를 호출한다. (전장의 AppModule 참조)
  • 27. Jamong Layer 별 모듈 구조 VDK Module Common Module App Module PlatformModule
  • 28. 참조 - 공식문서: https://angular.io/docs/ts/latest/guide/ngmodule.html - 설명문서: https://docs.google.com/document/d/1isijHlib4fnukj- UxX5X1eWdUar6UkiGKPDFlOuNy1U/pub#h.s0x91qpqpife - 모듈LifeCycle Hook: https://docs.google.com/document/d/1SCjDU1037CsAsXWs3tlFXFzhZtmotLw8_gcMrwlXOq o/edit