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
var Engine = (function(global) { | |
var doc = global.document, | |
win = global.window, | |
canvas = doc.createElement('canvas'), | |
ctx = canvas.getContext('2d'), | |
lastTime; | |
canvas.width = 505; | |
canvas.height = 606; | |
doc.body.appendChild(canvas); |
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
def menu | |
option_choice = get_input('') | |
case option_choice | |
when "1" | |
menu_start_game | |
when "2" | |
load | |
when "3" | |
menu_instruction | |
when "4", "X", "x", "Q", "q", :quit |
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
//rest the the entire form values and status. | |
this.userForm.reset(); | |
//rest the user name and it status. | |
this.userForm.reset({ | |
userName: '' | |
}); |
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
this.userForm.patchValue({ | |
userName: 'alexonozor' | |
}); |
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
this.userForm.setValue({ | |
userName: "AlexOnozor", | |
firstName: "Alex", | |
lastName: "Obogbare" | |
address: { ... } // reduce for brevity | |
}); |
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('', [ | |
Validators.required, | |
Validators.minLength(2), | |
forbiddenNameValidator(/bob/i) // <-- Here's how you pass in the custom validator. | |
]), | |
firstName: new FormControl('', [ Validators.required, Validators.minLength(2)]), | |
lastName: new FormControl(''), | |
address: new FormGroup({ | |
street: new FormControl('', Validators.required), |
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; | |
}; | |
} |
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('', [ Validators.required, Validators.minLength(4)]), | |
firstName: new FormControl('', [ Validators.required, Validators.minLength(2)]), | |
lastName: new FormControl(''), | |
address: new FormGroup({ | |
street: new FormControl('', Validators.required), | |
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
<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
<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> |
NewerOlder