Similar presentations:
Working with Directives and Pipes Presentation. Part 2
1.
ANGULAR 2PIPES
ANGULAR 2 BOOTCAMP
EPAM SARATOV · SPRING 2017
CONFIDENTIAL
1
2. About myself
ABOUT MYSELFFront-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 PIPESCONFIDENTIAL
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 PIPESEXAMPLE
http://plnkr.co/edit/5AKKFMJXXJKYziWX7ODN?p=preview
CONFIDENTIAL
15
16. CUSTOM PIPES
• How to make the custom pipe available everywhereCONFIDENTIAL
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.
EXAMPLEhttp://plnkr.co/edit/08HH8qArwZjOHqhGqXGK?p=preview
http://plnkr.co/edit/fJyipEbImeYypCFAPoiz?p=preview
CONFIDENTIAL
19
20. ASync Pipe
ASYNC PIPEEXAMPLE
http://plnkr.co/edit/9ICJ20kzzsHvwbrNS2Lk?p=preview
CONFIDENTIAL
20
21. HTML SANITAZE Pipe
HTML SANITAZE PIPECONFIDENTIAL
21
22. Useful links
USEFUL LINKS1. 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, RUSSIACONFIDENTIAL
23