About myself
Lesson plan
What are pipes on Angular 2?
Using Pipes
Using Pipes
Using Pipes
Built-in pipes
Built-in pipes
Built-in pipes
Built-in pipes
Built-in pipes
Built-in pipes
Built-in pipes
Custom Pipes
CUSTOM PIPES
Pure and impure pipes
Pure and impure pipes
ASync Pipe
HTML SANITAZE Pipe
Useful links
2.79M
Категория: МаркетингМаркетинг

Working with Directives and Pipes Presentation. Part 2

1.

ANGULAR 2
PIPES
ANGULAR 2 BOOTCAMP
EPAM SARATOV · SPRING 2017
CONFIDENTIAL
1

2. About myself

ABOUT MYSELF
Front-end developer
• 2 years
• Angular 1.x
• C# - ASP.NET MVC 3
Last project – trading system
(Angular 1, WebSockets, React,
SASS, Gulp …).
CONFIDENTIAL
2

3. Lesson plan

LESSON PLAN
•What are Pipes on Angular 2
•Use of Pipes
•Build-in Pipes
•Custom Pipes
•Pure and Impure Pipes
•Async Pipe
CONFIDENTIAL
3

4. What are pipes on Angular 2?

WHAT ARE PIPES ON ANGULAR 2?
• Pipes allow us to change data inside of a template
JavaScript
CONFIDENTIAL
Angular2
4

5. Using Pipes

USING PIPES
• General syntax(template)
<p>{{ expression | pipeName:parameter1:parameter2 }}</p>
• Chaining Pipes
CONFIDENTIAL
5

6. Using Pipes

USING PIPES
• Using in code
CONFIDENTIAL
6

7. Using Pipes

USING PIPES
• Using in code
CONFIDENTIAL
7

8. Built-in pipes

BUILT-IN PIPES
• DatePipe
CONFIDENTIAL
8

9. Built-in pipes

BUILT-IN PIPES
• SlicePipe
CONFIDENTIAL
9

10. Built-in pipes

BUILT-IN PIPES
CONFIDENTIAL
10

11. Built-in pipes

BUILT-IN PIPES
• UpperCasePipe
• LowerCasePipe
CONFIDENTIAL
11

12. Built-in pipes

BUILT-IN PIPES
• CurrencyPipe
https://en.wikipedia.org/wiki/ISO_4217
CONFIDENTIAL
12

13. Built-in pipes

BUILT-IN PIPES
• DecimalPipe
CONFIDENTIAL
13

14. Built-in pipes

BUILT-IN PIPES
• JsonPipe
CONFIDENTIAL
14

15. Custom Pipes

CUSTOM PIPES
EXAMPLE
http://plnkr.co/edit/5AKKFMJXXJKYziWX7ODN?p=preview
CONFIDENTIAL
15

16. CUSTOM PIPES

• How to make the custom pipe available everywhere
CONFIDENTIAL
16

17. Pure and impure pipes

PURE AND IMPURE PIPES
• Pure Pipes
Angular executes a pure pipe only when it detects a pure change to the input
value. A pure change is either a change to a primitive input value (String,
Number, Boolean, Symbol) or a changed object reference (Date, Array, Function,
Object).
Pipes are pure by default.
CONFIDENTIAL
17

18. Pure and impure pipes

PURE AND IMPURE PIPES
• Impure Pipes
Angular executes an impure pipe during every component change detection cycle.
An impure pipe will be called a lot, as often as every keystroke or mouse-move.
CONFIDENTIAL
18

19.

EXAMPLE
http://plnkr.co/edit/08HH8qArwZjOHqhGqXGK?p=preview
http://plnkr.co/edit/fJyipEbImeYypCFAPoiz?p=preview
CONFIDENTIAL
19

20. ASync Pipe

ASYNC PIPE
EXAMPLE
http://plnkr.co/edit/9ICJ20kzzsHvwbrNS2Lk?p=preview
CONFIDENTIAL
20

21. HTML SANITAZE Pipe

HTML SANITAZE PIPE
CONFIDENTIAL
21

22. Useful links

USEFUL LINKS
1. https://www.ng-book.com/2/
2. https://angular.io/docs/ts/latest/api/#!?apiFilter=pipe
3. https://angular.io/docs/ts/latest/guide/pipes.html
4. http://stackoverflow.com/questions/34456430/ngfor-doesnt-update-datawith-pipe-in-angular2
CONFIDENTIAL
22

23.

VADIM KHASHEV, SARATOV, RUSSIA
CONFIDENTIAL
23
English     Русский Правила