Don't write any code before you thinking clearly. There are lots of abstract concepts in Angular framework. If you want a better quality, faster development, lesser bugs of your Angular application. You need the "Zen" of Angular developments.
In this talk, Will will show you how to build Angular apps easily with just a few tips in mind.
Meetup: https://www.meetup.com/Angular-Vienna/events/267317982/
YouTube: https://youtu.be/2CBe7mZH3h8
The Zen of Angular Developments (Angular Vienna Meetup)
1. The Zen of Angular
Developments
Angular GDE / Microsoft MVP / Microsoft RD
Will Huang
http://blog.miniasp.com/
2. Angular Vienna Meetup
Will 保哥 (Will Huang)
• Founder of Duotify Inc. (Taiwan)
• Core Member of Angular Taiwan User Group
• 2018 ~ Now | Angular/Web GDE (Google Developer Expert)
• 2008 ~ Now | Microsoft MVP / Microsoft RD
• Blogger / YouTuber / Instructor / Consultant / Organizer
4. Angular Vienna Meetup
Concept First
• Angular Bootstrap Process
• Angular Execution Lifecycle
• Angular Forms
• Angular Routers
• Angular Components
• Third-party components
• State Managements
• Performance Tuning
• Unit testing & Integration tests
• Modules & Libraries
5. Angular Vienna Meetup
Then Speed
• Blind typing / Speed typing
• Accuracy first, then speed
• Mastering your dev tools
• Don't "type" if you don't have to
• Control the "Flow" state
• Eliminate all the distraction from your mind
7. Angular Vienna Meetup
Using Schematics for automation
• ng new demo1 --routing --style css
• ng generate component hello
• ng update
• Build your own code generation
• A great sample/tutorial from Manfred Steyer's Angular CRUD
• ng g angular-crud:crud-module hotel
• ng add @angular/elements
• ng add @angular/material
• ng add @angular/pwa
• ng add @clr/angular
• ng add @nativescript/schematics
• ng add ng-zorro-antd
• ng add ngcli-wallaby
15. Angular Vienna Meetup
Angular Language Service
• Completions lists
• AOT Diagnostic messages
• Quick info
• Go to definition
16. Angular Vienna Meetup
• Switch to TEMPLATE ( *.html )
• Shoftcut:alt+o (Windows) / shift+alt+o (macOS)
• Switch to CSS ( *.css )
• Shortcut:alt+i (Windows) / shift+alt+i (macOS)
• Switch to TypeScript ( *.ts )
• Shortcut:alt+u (Windows) / shift+alt+u (macOS)
• Switch to Spec file ( *.spec.ts )
• Shortcut:alt+p (Windows) / shift+alt+p (macOS)
Switching between files in a component
17. Angular Vienna Meetup
Use Code Snippets
• Use Code Snippets as much as you can
• ng-import-* import common Angular modules or services
• a-* Angular Snippets
• ng-* Angular Snippets
• ngrx-* Angular NgRx Snippets
• ngxs-* Angular Ngxs Snippets
• m-* Angular Material Design Snippets
• rx-* RxJS Snippets for both TypeScript and JavaScript
18. Angular Vienna Meetup
Use TSLint to improve code quality
• Command
• TSLint: Fix all auto-fixable problems ( Command: tslint.fixAllProblems )
• TSLint core rules ( tslint.json )
• import-blacklist
• prefer-const
• Fix all auto-fixable problems when on save (VSCode Settings)
"editor.codeActionsOnSave": {
"source.fixAll.tslint": true
}
19. Angular Vienna Meetup
TypeScript Refactoring
• Code Actions = Quick Fixes
• Ctrl+.
• Rename symbol
• F2
• Change All Occurrences
• Ctrl+F2 / CMD+F2
• Move TS
• Move TypeScript files and update
relative imports
• Refactoring actions
• Extract Method
• Extract Variable
• Extract function
• Extract constant
• Suggestion Code Action ( ... )
• Generate 'get' and 'set' accessors
• Move to new file
• Convert to async function
• Convert between named imports and namespace imports
20. Angular Vienna Meetup
TypeScript type definition
• JSON to TS
• Ctrl+Alt+V Convert from clipboard
• Ctrl+Alt+S Convert from selection
• Paste JSON as Code
• Support TypeScript, Python, Go, Ruby, C#, Java, Swift, Rust, Kotlin, C++, Flow, Objective-C,
JavaScript, Elm, and JSON Schema
• Choose Language Mode first, then run "Paste JSON as Code/Type" Command
• Paste JSON as Code ( Command: quicktype.pasteJSONAsTypesAndSerialization )
• Paste JSON as Type ( Command: quicktype.pasteJSONAsTypes )
21. Angular Vienna Meetup
• Document This
• Just hit Ctrl+Alt+D twice
Auto-generate code comments
22. Angular Vienna Meetup
• https://angular.io/guide/styleguide
• If you have time, read it.
• If you don't have time, forget it.
• Just let ng generate scaffold the code for you.
• Just run ng lint to check the code styles ( codelyzer )
• Just use TSLint to "Fix all auto-fixable problems"
Following the Angular Style Guide
Try latest Angular CLI Beta / RC, with Angular v7 and the new Ivy compiler, no install required thanks to npm and npx
https://www.gurustop.net/blog/2018/10/11/4258/npm-npx-angular-beta-rc-next-angular-cli-ivy-compiler
Try latest Angular CLI Beta / RC, with Angular v7 and the new Ivy compiler, no install required thanks to npm and npx
https://www.gurustop.net/blog/2018/10/11/4258/npm-npx-angular-beta-rc-next-angular-cli-ivy-compiler