programming:angular
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| programming:angular [2023/07/26 06:00] – skipidar | programming:angular [2023/11/01 07:31] (current) – ↷ Page moved from camunda:programming:angular to programming:angular skipidar | ||
|---|---|---|---|
| Line 16: | Line 16: | ||
| == let == | == let == | ||
| - | use ''' | + | use '' |
| - | Dont use ''' | + | Dont use '' |
| - | Typescript resolves the conflicts between scopes on its own, when using ''' | + | Typescript resolves the conflicts between scopes on its own, when using '' |
| Line 163: | Line 163: | ||
| Watch changes in code and auto rebuild | Watch changes in code and auto rebuild | ||
| + | < | ||
| + | ng build --watch --poll 500 --configuration development | ||
| + | </ | ||
| + | |||
| + | To check if any module in a project is ' | ||
| + | |||
| + | To update all dependencies, | ||
| + | |||
| + | To update all dependencies, | ||
| + | |||
| + | To update package.json version numbers, append the --save flag: '' | ||
| < | < | ||
| ng build --watch --poll 500 --configuration development | ng build --watch --poll 500 --configuration development | ||
| Line 391: | Line 402: | ||
| - | TypeScript eliminates this boilerplate of using '''" | + | TypeScript eliminates this boilerplate of using ''" |
| accessors on the constructor parameters. | accessors on the constructor parameters. | ||
| Line 761: | Line 772: | ||
| A new **component** " | A new **component** " | ||
| - | ''' | + | '' |
| <sxh ts> | <sxh ts> | ||
| import {Component, Input} from ' | import {Component, Input} from ' | ||
| Line 783: | Line 794: | ||
| Because a field " | Because a field " | ||
| - | ''' | + | '' |
| <sxh ts> | <sxh ts> | ||
| Line 792: | Line 803: | ||
| - | ''' | + | '' |
| Define a " | Define a " | ||
| Line 814: | Line 825: | ||
| And I bind the title field of root component to it. | And I bind the title field of root component to it. | ||
| - | ''' | + | '' |
| <sxh ts> | <sxh ts> | ||
| < | < | ||
| Line 825: | Line 836: | ||
| A new **component** " | A new **component** " | ||
| - | ''' | + | '' |
| <sxh ts> | <sxh ts> | ||
| import {Component, Input} from ' | import {Component, Input} from ' | ||
| Line 846: | Line 857: | ||
| Because a field " | Because a field " | ||
| - | ''' | + | '' |
| <sxh html> | <sxh html> | ||
| Line 875: | Line 886: | ||
| And I bind the '' | And I bind the '' | ||
| - | ''' | + | '' |
| <sxh ts> | <sxh ts> | ||
| < | < | ||
| Line 1161: | Line 1172: | ||
| ... | ... | ||
| + | </ | ||
| + | |||
| + | |||
| + | The component stub can be generated. | ||
| + | |||
| + | Also under a " | ||
| + | |||
| + | |||
| + | < | ||
| + | ng generate component heroes/ | ||
| </ | </ | ||
| Line 1509: | Line 1530: | ||
| More: https:// | More: https:// | ||
| + | |||
| + | |||
| + | |||
| + | ===== Async patterns ===== | ||
| + | |||
| + | |||
| + | == Promises == | ||
| + | |||
| + | * They cannot be canceled. | ||
| + | * They are immediately executed. | ||
| + | * They are one-time operations only; there is no easy way to retry them. | ||
| + | * They respond with only one value. | ||
| + | |||
| + | |||
| + | <sxh ts> | ||
| + | private onComplete() { | ||
| + | return new Promise((resolve, | ||
| + | | ||
| + | | ||
| + | }, 2000); | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | |||
| + | private setTitle = () => { | ||
| + | this.title = 'Hello Angular 10'; | ||
| + | } | ||
| + | |||
| + | constructor() { | ||
| + | this.onComplete().then(this.setTitle); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | == Observers == | ||
| + | |||
| + | |||
| + | |||
| + | <sxh ts> | ||
| + | |||
| + | // triggers every 2 sec his observables | ||
| + | title$ = new Observable(observer => { | ||
| + | setInterval(() => { | ||
| + | observer.next(); | ||
| + | }, 2000); | ||
| + | }); | ||
| + | |||
| + | |||
| + | private setTitle = () => { | ||
| + | const timestamp = new Date().getMilliseconds(); | ||
| + | this.title = `Hello Angular 10 (${timestamp})`; | ||
| + | } | ||
| + | |||
| + | constructor() { | ||
| + | this.title$.subscribe(this.setTitle); | ||
| + | } | ||
| + | </ | ||
programming/angular.1690351211.txt.gz · Last modified: by skipidar
