90 |
198 |
--------------------------------------------------------------------------------
/example/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import {
2 | ChangeDetectionStrategy,
3 | Component,
4 | Inject,
5 | OnInit,
6 | ViewEncapsulation
7 | } from "@angular/core";
8 | import { FormBuilder, FormControl, FormGroup, NgForm, Validators } from "@angular/forms";
9 |
10 | @Component( {
11 | selector : "in-app",
12 | templateUrl : "./app.component.html",
13 | styles : ["pre { background-color: whitesmoke;} small {color: #AAA}"],
14 | encapsulation : ViewEncapsulation.None,
15 | changeDetection: ChangeDetectionStrategy.OnPush
16 | } )
17 | export class AppComponent implements OnInit {
18 | trigger: FormControl;
19 |
20 | exampleForm: FormGroup;
21 |
22 | exampleFormInfo = {};
23 |
24 | constructor( @Inject( FormBuilder ) private fb: FormBuilder ) {
25 | this.trigger = this.fb.control( "input" );
26 |
27 | this.exampleForm = this.fb.group( {
28 | text : ["Booobbb "],
29 | text_undefined: [undefined],
30 | text_disabled : { value: "I'm disabled", disabled: true },
31 | text_autofill : [undefined],
32 | email : ["", [Validators.email]],
33 | number : ["", []],
34 | url : ["", []],
35 | textarea : ["", [Validators.maxLength( 10 )]]
36 | } );
37 |
38 | this.updateStates();
39 | }
40 |
41 | ngOnInit() {
42 | this.exampleForm.controls.text_undefined.setValue( undefined );
43 | }
44 |
45 | /**
46 | * ngFor Helper
47 | */
48 | getKeys( obj: Object ): Array