01. Install angular CLI
npm -g install @angular/cli
npm install -g @angular/cli@latest
02. Check angular is installed on your machine .
ng version
Sometime node may not have to work .So update angular cli with node
03. Create a project with route
ng new crmapp –route
04. Create a component
ng generate component ContactList –route
05.Create routing
ng generate module app-routing –flat –module=app
06.Create a component inside a module
ng g component newComponent
and
ng g component moduleName/newComponent
01. Validators
Only integer with pattern
1 |
Validators.pattern('/^-?[0-9][^\\.]*$/') |
Range between two number .
1 2 3 4 5 6 7 8 |
export function RangeValidator(min: number, max: number): ValidatorFn { return (control: AbstractControl): { [key: string]: boolean } | null => { if (control.value !== undefined && (isNaN(control.value) || control.value < min || control.value > max)) { return { 'ageRange': true }; } return null; }; } |