Skip to content

Instantly share code, notes, and snippets.

View alexonozor's full-sized avatar
🏠
Working from home

Alex Onozor alexonozor

🏠
Working from home
View GitHub Profile
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('')
})
});
<form [formGroup]="userForm" novalidate>
<div class="form-group">
<label class="center-block">userName:
<input class="form-control" formControlName="userName">
</label>
</div>
</form>
import { FormControl, FormGroup } from '@angular/forms'; // notice we also import FormGroup
export class UsersComponent {
userForm = new FormGroup ({
userName: new FormControl()
});
}
<label class="center-block">userName:
<input class="form-control" [formControl]="userName">
</label>
import { FormControl } from ‘@angular/forms’;
export class UserComponent { 
userName = new FormControl(); 
}
@alexonozor
alexonozor / flatten.js
Created October 7, 2016 10:51
Xample method for Array#flatten
function flatten(arr) {
return arr.reduce(function (flat, toFlatten) {
return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
}, []);
}
This file has been truncated, but you can view the full file.
{
"biodata": [
{
"JambRegNo": "011/02/CSC/1034",
"MatricNo": "011/02/CSC/1034",
"Title": "Mr",
"Surname": "Abdallah",
"FirstName": "Maryam",
"MiddleName": "",
"MaritalStatus": "",