没有合适的资源?快使用搜索试试~ 我知道了~
首页ng-book2-angular-5-r65
资源详情
资源评论
资源推荐

By XINCONAN

ng-book
The Complete Guide to Angular
Wri!en by Nate Murray, Felipe Coury, Ari Lerner, and Carlos Taborda
© 2017 Fullstack.io
All rights reserved. No portion of the book manuscript may be reproduced, stored in a retrieval
system, or transmi!ed in any form or by any means beyond the number of purchased copies,
except for a single backup or archival copy. "e code may be used freely in your projects,
commercial or otherwise.
"e authors and publisher have taken care in preparation of this book, but make no expressed
or implied warranty of any kind and assume no responsibility for errors or omissions. No
liability is assumed for incidental or consequential damagers in connection with or arising out
of the use of the information or programs container herein.
Published in San Francisco, California by Fullstack.io.
!
FULLSTACK
.io

Contents
Book Revision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Bug Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chat With The Community! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Vote for New Content (new!) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Be notified of updates via Twitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
We’d love to hear from you! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
How to Read This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Running Code Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Angular CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Code Blocks and Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Code Block Numbering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
A Word on Versioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Emailing Us . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Technical Support Response Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Chapter Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Writing Your First Angular Web Application . . . . . . . . . . . . . . . . . . . . . . . . . 1
Simple Reddit Clone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Node.js and npm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
TypeScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Special instruction for Windows users . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Angular CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Example Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Writing Application Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Running the application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Making a Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Importing Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Component Decorators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Adding a template with templateUrl . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Adding a template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

CONTENTS
Adding CSS Styles with styleUrls . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Loading Our Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Adding Data to the Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Working With Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Using the User Item Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Rendering the UserItemComponent . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Accepting Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Passing an Input value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Bootstrapping Crash Course . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
imports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
bootstrap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Expanding our Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Adding CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
The Application Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Adding Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Adding the Article Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Rendering Multiple Rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Creating an Article class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Storing Multiple Articles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Configuring the ArticleComponent with inputs . . . . . . . . . . . . . . . . . . . . . 53
Rendering a List of Articles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Adding New Articles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Finishing Touches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Displaying the Article Domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Re-sorting Based on Score . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Building Our App for Production . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Uploading to a Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Installing now . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Full Code Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Wrapping Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
TypeScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Angular 4 is built in TypeScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
What do we get with TypeScript? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Trying it out with a REPL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Built-in types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
剩余681页未读,继续阅读

















安全验证
文档复制为VIP权益,开通VIP直接复制

评论2