-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Model Driven Forms - Form Controls
- Loading branch information
Showing
3 changed files
with
55 additions
and
21 deletions.
There are no files selected for viewing
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,37 @@ | ||
import { Component } from '@angular/core'; | ||
import { FormGroup, FormControl } from '@angular/forms'; | ||
|
||
import { validateEmailFactory } from './../../shared/validators/email.validator'; | ||
import { CheckboxValidator } from './../../shared/validators/checkbox-checked.validator'; | ||
|
||
@Component({ | ||
selector: 'labs-model-controls', | ||
templateUrl: 'model-controls.component.html' | ||
}) | ||
export class ModelControlsComponent {} | ||
export class ModelControlsComponent { | ||
form: FormGroup; | ||
|
||
constructor() { | ||
|
||
this.form = new FormGroup({ | ||
email: new FormControl(null, validateEmailFactory()), | ||
firstName: new FormControl(), | ||
lastName: new FormControl(), | ||
gender: new FormControl(), | ||
notrobot: new FormControl(null, CheckboxValidator.checked), | ||
address: new FormGroup({ | ||
addressLine1: new FormControl(), | ||
addressLine2: new FormControl(), | ||
city: new FormControl(), | ||
zipCode: new FormControl(), | ||
landmark: new FormControl(), | ||
addressType: new FormControl(), | ||
country: new FormControl() | ||
}) | ||
}); | ||
} | ||
|
||
signUp(data: any) { | ||
console.log('Submit the data: ', data); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | ||
import { ModelControlsComponent } from './model-controls.component.ts'; | ||
import { Bootstrap4FormsModule } from '../../shared/bootstrap4/forms'; | ||
|
||
import { moduleRoutes } from './model-controls.routes.ts'; | ||
|
||
@NgModule({ | ||
imports: [ moduleRoutes ], | ||
imports: [ Bootstrap4FormsModule, CommonModule, FormsModule, ReactiveFormsModule, moduleRoutes ], | ||
declarations: [ ModelControlsComponent ] | ||
}) | ||
export class ModelControlsModule {} |