Practical Angular 2.pdf

(6381 KB) Pobierz
Practical Angular 2 Book
With Node/npm, Typescript, SystemJS and Visual Studio Code
Daniel Schmitz and Daniel Pedrinha Georgii
This book is for sale at http://leanpub.com/practical-angular-2
This version was published on 2016-01-31
* * * * *
This is a
Leanpub
book. Leanpub empowers authors and publishers with the Lean
Publishing process. Lean Publishing is the act of publishing an in-progress ebook using
lightweight tools and many iterations to get reader feedback, pivot until you have the right
book and build traction once you do.
* * * * *
© 2015 - 2016 Daniel Schmitz and Daniel Pedrinha Georgii
Table of Contents
1. Introduction
1.1 Prerequisites
1.1.1 Node
1.1.2 Web server
1.1.3 The package.json file
1.1.4 Text editors and IDEs
1.2 Besides Javascript
1.3 TypeScript
1.4 Source code
2. TypeScript
2.1 Installing TypeScript
2.2 Using Visual Studio Code
2.2.1 Detecting changes
2.2.2 Debugging Visual Studio Code
2.2.3 Debug on the browser
2.3 Types
2.3.1 Basic types
2.3.2 Arrays
2.3.3 Enum
2.3.4 Any
2.3.5 Void
2.4 Classes
2.4.1 Constructor
2.4.2 Method and properties visibility
2.5 Heritage
2.6 Accessors (get/set)
2.7 Static Methods
2.8 Interfaces
2.9 Functions
2.9.1 Default value
2.9.2 Optional parameter
2.10 Rest parameters
2.11 Parameters in JSON format
2.12 Modules
2.12.1 Example with Systemjs
2.12.2 Hiding js e map files on VSCode
2.12.3 Using SystemJS
2.13 Decorators (or annotation)
2.14 Conclusion
3. Let’s practice
3.1 AngularBase Project
3.1.1 Setting up the project
3.1.2 Setting up the TypeScript compilation
3.1.3 Creating the first Angular 2 component
3.1.4 Creating the bootstrap
3.1.5 Creating an HTML file
3.2 Creating a playlist
3.2.1 Initial file structure
3.2.2 Creating the application settings file
3.2.3 Adding the bootstrap
3.2.4 Creating the Video class
3.2.5 Creating a simple video list
3.2.6 Creating child components
3.2.7 Formatting the template
3.2.8 Passing values between components
3.2.9 Selecting a video
3.2.10 Events
3.2.11 Event Bubbling
3.2.12 Showing the video details
3.2.13 Editing the selected video data
3.2.14 Editing the title
3.2.15 Creating a new item
3.2.16 Some considerations
3.3 Creating Components
3.4 Hierarchical components
4. Some theory
4.1 Overview
4.2 Module
4.2.1 Library Module
4.3 Component
4.4 Template
4.4.1 Interpolation (Using {{ }})
4.4.2 Template Expressions
4.5 Property Bind
4.5.1 Loops
4.5.2 Pipes (Operator |)
4.6 Metadata (annotation)
4.7 Service
4.8 Dependency injection
4.8.1 Using the @Injectable()
4.9 Using the ngControl
4.10 Showing an error message
4.11 Disabling the submit button of the form
4.12 Submitting the form
4.13 Controlling the form visibility
5. Connecting to a server
5.1 Creating the project
5.2 Using the Http class
5.3 Using services
5.4 Organizing the project
5.5 User model
5.6 User service
5.7 Changing the AppComponent component
5.8 Submitting data
Zgłoś jeśli naruszono regulamin