Posted on14 Apr 2019 | Byadmin

Route Guards

 

 

CanActivate

 

Posted on13 Apr 2019 | Byadmin

Pipes in angular are for transforming data.  Pipes are denoted using the "|" character.  A commonly used pipe would be the upper case pipe which converts a string variable to all uppercase letters.

Example:

<h1>Uppercase Pipe</h1>

<b>{{title | uppercase}}</b>

Custom Pipe

To create a custom pipe a class is created decorated with @Pipe in a typescript file.

Example:

Posted on13 Apr 2019 | Byadmin
Posted on13 Apr 2019 | Byadmin

In reactive forms validator functions are added to the FormGroup object in the component class.  When a control value changes Angular will call the corresponding validator functions.

Sync Validators

Sync validator functions return either a set of validation errors or null.

Async Validators

Async validators functions return a promise or observable that will later emit null or a set of validation errors.

Posted on13 Apr 2019 | Byadmin

Form Model

Angular Reactive Forms requires a model be created specifically for the purpose of supporting the form.  this is usually referred to as the form model.  The main purpose of this is so that the original data object is not over written until the user wishes to submit the form.  Once submit is pressed on the form then the original data object is copied over with the data from the form model.  Overriding the object like this is referred to as "immutable objects"

Posted on12 Apr 2019 | Byadmin

Input properties are denoted with the @Input

 

EventEmitters are denoted with the decorator @Output

Posted on10 Apr 2019 | Byadmin

 

 

ngOnChanges()

 

ngOnInit()

 

ngDoCheck()

 

ngAfterContentInit()

 

ngAfterContentChecked()

 

ngAfterViewInit()

 

ngAfterViewChecked()

 

Posted on10 Apr 2019 | Byadmin

Angular apps consist of a tree of components.  Components are a subset of directives.  Components are always associated with one template.

NgModule

A component must belong to a NgModule in order for it to be available to the application to use.  A NgModule must declare a component in the declarations field of the metadata.

Posted on08 Apr 2019 | Byadmin

Angular uses  Rx.js to write asynchronous code. Rx.js provides observables, subjects, subject behaviour and promises to write asynchronous code.

Promises

If a function returns a promise you can use the ".then" callback function.  For example someFunctionThatReturnsAPromise().then("print something off on the screen a few seconds later").