Modules
|
|
Components
|
|
| @HostBinding - sets a property to the host element which is the custom HTML tag specified in the `selector` (host) component property |
|
| @HostListener - allows you to subscribe to the events of the DOM element. |
Talking to the DOM directly is not considered best practice @HostListener will be triggered for every HTML element if you have multiple root nodes in your templates like below |
|
Content projection using |
|
|
Component Lifecycle Hooks in order of execution:
|
|
| Angular’s default change detection uses the Zones library |
|
|
Angular offers Default and OnPush |
|
Templates
| The component's view |
|
Metadata
| Tells Angular how to process a class |
|
Data Binding
|
|
| @Input - allows data to flow from the binding expression (template) into the directive (component). |
Template: Component Class:
|
| @Output - expose event producers, such as EventEmitter objects. An output property streams an event “out” of the component |
Template for MyComponent MyComponent OtherComponent |
Directives
|
|
| @Directie exportAs property - allows you to reference a DOM element in your template like a local variable |
|
Services
|
|
Dependency Injection
|
|
Routing
|
Dependencies:
|
|
|
Url Parsing strategies:
|
Sample Code: |
| Import ActivatedRoute for handling dynamic urls and query string parameters. |
|
| Import `CanActivate` from ‘@angular/router` for restricted routes |
Guarding routes that are behind a login can be configured as |
Observables
|
|
| Outputting data to the template: https://auth0.com/blog/making-use-of-rxjs-angular/ |
|
| Hot or Cold Observable |
|
Ahead of Time Compilation
|
|
Injectables
|
|
|
|
Pipes
| Pipes - a way to write display-value transformations that you can declare in your HTML. |
|