This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"biodata": [ | |
{ | |
"JambRegNo": "011/02/CSC/1034", | |
"MatricNo": "011/02/CSC/1034", | |
"Title": "Mr", | |
"Surname": "Abdallah", | |
"FirstName": "Maryam", | |
"MiddleName": "", | |
"MaritalStatus": "", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function flatten(arr) { | |
return arr.reduce(function (flat, toFlatten) { | |
return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten); | |
}, []); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { FormControl } from ‘@angular/forms’; | |
export class UserComponent { | |
userName = new FormControl(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<label class="center-block">userName: | |
<input class="form-control" [formControl]="userName"> | |
</label> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { FormControl, FormGroup } from '@angular/forms'; // notice we also import FormGroup | |
export class UsersComponent { | |
userForm = new FormGroup ({ | |
userName: new FormControl() | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form [formGroup]="userForm" novalidate> | |
<div class="form-group"> | |
<label class="center-block">userName: | |
<input class="form-control" formControlName="userName"> | |
</label> | |
</div> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const userForm = new FormGroup({ | |
userName: new FormControl(''), | |
firstName: new FormControl(''), | |
lastName: new FormControl(''), | |
address: new FormGroup({ | |
street: new FormControl(''), | |
city: new FormControl(''), | |
zipCode: new FormControl('') | |
}) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div formGroupName="address" class="well well-lg"> | |
<div class="form-group"> | |
<label class="center-block">Street: | |
<input class="form-control" formControlName="street"> | |
</label> | |
</div> | |
<div class="form-group"> | |
<label class="center-block">City: | |
<input class="form-control" formControlName="city"> | |
</label> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p>UserName value: {{ userForm.get('userName').value }}</p> | |
//Get the street of the nested address | |
<p>Street value: {{ userForm.get('address.street').value}}</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** A user name can't match the given regular expression */ | |
export function forbiddenUserNameValidator(nameRe: RegExp): ValidatorFn { | |
return (control: AbstractControl): {[key: string]: any} => { | |
const forbidden = nameRe.test(control.value); | |
return forbidden ? {'forbiddenName': {value: control.value}} : null; | |
}; | |
} |
OlderNewer