SlideShare une entreprise Scribd logo
1  sur  28
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

Contenu connexe

Tendances

1.스프링프레임워크 개요
1.스프링프레임워크 개요1.스프링프레임워크 개요
스프링프레임워크 & 마이바티스 무.료 강의자료 제공 (Spring IoC & DI)_ 구로자바학원/구로오라클학원/구로IT학원
스프링프레임워크 & 마이바티스 무.료 강의자료 제공 (Spring IoC & DI)_ 구로자바학원/구로오라클학원/구로IT학원스프링프레임워크 & 마이바티스 무.료 강의자료 제공 (Spring IoC & DI)_ 구로자바학원/구로오라클학원/구로IT학원
스프링프레임워크 & 마이바티스 무.료 강의자료 제공 (Spring IoC & DI)_ 구로자바학원/구로오라클학원/구로IT학원
탑크리에듀(구로디지털단지역3번출구 2분거리)
 

Tendances (20)

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

En vedette

583: Review of iPhone Applications for Diabetes Self-Management
583: Review of iPhone Applications for Diabetes Self-Management583: Review of iPhone Applications for Diabetes Self-Management
583: Review of iPhone Applications for Diabetes Self-Management
yan_stanford
 
Quantified Self and the Self-tracking Patient (Body Media)
Quantified Self and the Self-tracking Patient (Body Media)Quantified Self and the Self-tracking Patient (Body Media)
Quantified Self and the Self-tracking Patient (Body Media)
yan_stanford
 
741: Integrating Open Source Web 2.0 and Smartphone Technologies to Automate ...
741: Integrating Open Source Web 2.0 and Smartphone Technologies to Automate ...741: Integrating Open Source Web 2.0 and Smartphone Technologies to Automate ...
741: Integrating Open Source Web 2.0 and Smartphone Technologies to Automate ...
yan_stanford
 
Issues in Mobile Health (Barbara Mittleman)
Issues in Mobile Health (Barbara Mittleman)Issues in Mobile Health (Barbara Mittleman)
Issues in Mobile Health (Barbara Mittleman)
yan_stanford
 

En vedette (12)

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

Similaire à Angular2 NgModule

Component configurator
Component configuratorComponent configurator
Component configurator
scor7910
 
[1A5]효율적인안드로이드앱개발
[1A5]효율적인안드로이드앱개발[1A5]효율적인안드로이드앱개발
[1A5]효율적인안드로이드앱개발
NAVER D2
 
오픈소스 소프트웨어 성능 최적화 보고서 6장
오픈소스 소프트웨어 성능 최적화 보고서 6장오픈소스 소프트웨어 성능 최적화 보고서 6장
오픈소스 소프트웨어 성능 최적화 보고서 6장
JamGun
 
Jpa 쿼리 포함 자료
Jpa 쿼리 포함 자료Jpa 쿼리 포함 자료
Jpa 쿼리 포함 자료
Hyosang Hong
 
[2022]Flutter_IO_Extended_Korea_멀티모듈을활용한플러터클린아키텍처_...
[2022]Flutter_IO_Extended_Korea_멀티모듈을활용한플러터클린아키텍처_...[2022]Flutter_IO_Extended_Korea_멀티모듈을활용한플러터클린아키텍처_...
[2022]Flutter_IO_Extended_Korea_멀티모듈을활용한플러터클린아키텍처_...
Taekyu Lim
 

Similaire à Angular2 NgModule (20)

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

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