1. Trang chủ
  2. » Giáo án - Bài giảng

14 1 lifecycle tủ tài liệu training pdf

48 41 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 48
Dung lượng 94,81 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Called after a bound input property changes Called once the component is initialized Called during every change detection run Called after content ng-content has been projected into view

Trang 1

Called after a bound input property changes

Called once the component is initialized

Called during every change detection run

Called after content (ng-content) has been projected into view

Called every time the projected content has been checked

Called after the component’s view (and child views) has been initialized

Called every time the view (and child views) have been checked

Called once the component is about to be destroyed

Trang 2

Understanding Directives

Trang 3

Attribute vs Structural

Look like a normal HTML Attribute

(possibly with databinding or event

Trang 4

Services &

Dependency Injection

Trang 5

What are Services?

Application

AppComponent

UserComponentAboutComponent

UserDetailComponent

LogService

UserService

log data to console

log data to consolestore user dataCentralization

Data Storage

Trang 6

Hierarchical Injector

AppModule

AppComponent

Any other Component

Same Instance of Service is available Application-wide

Same Instance of Service is available for all Components (but not for other Services)

Same Instance of Service is available for the Component and all its child components

Trang 7

Pipes

Trang 8

Routing

Trang 9

Forms

Trang 10

Form is created programmatically and

synchronized with the DOM

Trang 11

Http

Trang 12

Authentication

Trang 13

How does Authentication work?

Identify viaCookie

Server stores the Session!

Client (Frontend)

Server (Backend)

Send AuthInformation

Server doesn’t remember the Client!

Send Token

Authenticatevia Token

Trang 14

Animations

Trang 15

Using Modules &

Optimizing an Angular

App

Trang 16

The Idea behind App Modules

Component

Component

Directive

Module

Trang 18

Shared Modules

Component

Component

AppModule FeatureModule1

Component

Component

DirectiveDirective

FeatureModule2

Shared Module

Trang 19

Modules and Routing (Lazy Loading)

Trang 20

Why Modules?

Don‘t bloat the AppModule

Be clear about Who‘s responsible for What

Allows Lazy Loading of Modules

Trang 21

Modules and Service Injection

One Instance of LogService

Loaded at Application Launch:

Provided on Root Level

Uses Root Injector

Trang 22

Modules and Service Injection

AppModule

providers: [LogService]

Root Injector

One Instance of LogService

Child Injector

One Instance of LogService

Loaded at Application Launch:

Provided on Root Level

Loaded Lazily:

Provided on Module Level only

Enforce "Module Scope" by providing in a Component instead of a Module!

Trang 23

Modules and Service Injection

One Instance of LogService

Loaded at Application Launch:

Provided on Root Level

Trang 24

Modules and Service Injection

One Instance of LogService

Loaded at Application Launch:

Provided on Root Level

Lazy Loaded Module uses Child Injector

Don‘t provide Services in Shared Modules!

Especially not, if you plan to use them in Lazy Loaded

Modules!

Trang 25

Feature Module

Core Module

Trang 26

Ahead-of-Time Compilation

Development

Production

App downloaded in Browser

Angular Parses & Compiles Templates (to

JavaScript)

Development

Production

App downloaded in Browser

Angular Parses & Compiles Templates (to

JavaScript)

Trang 27

Advantages of AoT Compilation

Faster Startup sind Parsing and Compilation doesn‘t happen in Browser

Templates get checked during Development

Smaller File Size as unused Features can be stripped out and the Compiler itself isn‘t shipped

Trang 28

Testing

Trang 29

Deployment

Trang 30

Deployment Steps & Things to Keep in Mind

Build your App for ProductionConsider AoT Compilation

Set the correct <base> elementFor example.com/my-appyou should have <base href=“/my-app/”>

Make sure your Server ALWAYS returns index.html

Routes are registered in Angular App, so the server won’t know your

routes! Return index.htmlin case of 404 errors!

Trang 31

What are Directives?

Directives are Instructions in the DOM!

<p appTurnGreen >Receives a green background!</p>

@Directive({

selector: ' [appTurnGreen] ' })

export class TurnGreenDirective {

… }

Trang 32

Course Project

Trang 33

Planning the App

FeatureRecipe

Trang 34

Dropdown

Trang 35

Recipe

Service

RecipeShopping List

Trang 36

Recipe

Service

RecipeShopping List

Recipe Edit

Trang 37

Recipe

Service

RecipeShopping List

Recipe Edit

TD

R

Forms

Trang 38

Recipe

Service

RecipeShopping List

Recipe Edit

TD

R

Forms

Trang 39

What changed in the Course Update?

Trang 40

Angular 4 is NOT a re-write of Angular 2!

Angular Team switched to Semantic Versioningand renamed Angular 2 to Angular

(Angular 1 will be AngularJS)

Semantic Versioning

MAJOR.MINOR.BUGFIX

e.g 2.4.3e.g 4.0.1

Angular 4 is only an updateto Angular 2 (now only “Angular”)

Trang 44

Improved Content

Tried to sharpen Explanations in all Modules

More Details in Routing , Forms and OptimizationsModuleChanged Authentication Module to now use the Recipe Book

The Deployment Section now uses the Recipe Book as an Example

Added a Basics Section to learn the Core Features Faster

Trang 45

How to Continue

"Old Content" is kept around until end of April

(I will inform you before it‘s removed!)

Keep in mind: Angular 2 Syntax = Angular 4 Syntax

The "old Content" is still correct!

You don‘t have to go through the updated Content at all!

Download "old" lectures!

Trang 46

How to Continue (if you want to use the new Content)

Getting StartedComponentsCourse ProjectDirectivesCourse ProjectServices

Course Roundup

Getting StartedBasicsCourse ProjectComponentsCourse ProjectDirectives

Trang 47

How to Continue (if you want to use the new Content)

Getting Started

RoutingCourse ProjectForms

Course Roundup

Restart at Routing/Forms/ …Download latest UpdatedRecipe Book Project

Trang 48

How to Continue (if you want to use the new Content)

Getting Started

RoutingCourse ProjectForms

Ngày đăng: 17/11/2019, 07:35