-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(demo): fix buttons reactive forms sample
- Loading branch information
Showing
4 changed files
with
20 additions
and
28 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
9 changes: 2 additions & 7 deletions
9
demo/src/app/components/+buttons/demos/checkbox/checkbox.html
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
22 changes: 9 additions & 13 deletions
22
demo/src/app/components/+buttons/demos/radio-reactiveforms/radio-reactiveforms.html
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,17 +1,13 @@ | ||
<pre class="card card-block card-header">{{myForm.controls.myControl.value}}</pre> | ||
<pre class="card card-block card-header">{{myForm.value | json}}</pre> | ||
<form [formGroup]="myForm"> | ||
<div class="btn-group"> | ||
<label class="btn btn-primary" [class.active]="myForm.controls.myControl.value == 'Left'"> | ||
<input type="radio" formControlName="myControl" style="display:none" value="Left"> | ||
Left | ||
</label> | ||
<label class="btn btn-primary" [class.active]="myForm.controls.myControl.value == 'Middle'"> | ||
<input type="radio" formControlName="myControl" style="display:none" value="Middle"> | ||
Middle | ||
</label> | ||
<label class="btn btn-primary" [class.active]="myForm.controls.myControl.value == 'Right'"> | ||
<input type="radio" formControlName="myControl" style="display:none" value="Right"> | ||
Right | ||
</label> | ||
<label class="btn btn-primary" [class.active]="myForm.value.left" | ||
btnCheckbox formControlName="left">Left</label> | ||
|
||
<label class="btn btn-primary" [class.active]="myForm.value.middle" | ||
btnCheckbox formControlName="middle">Middle</label> | ||
|
||
<label class="btn btn-primary" [class.active]="myForm.value.right" | ||
btnCheckbox formControlName="right">Right</label> | ||
</div> | ||
</form> |
15 changes: 8 additions & 7 deletions
15
demo/src/app/components/+buttons/demos/radio-reactiveforms/radio-reactiveforms.ts
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,20 +1,21 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component, OnInit } from '@angular/core'; | ||
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | ||
|
||
@Component({ | ||
selector: 'demo-buttons-radio-reactiveforms', | ||
templateUrl: './radio-reactiveforms.html' | ||
}) | ||
export class DemoButtonsRadioReactiveFormsComponent { | ||
export class DemoButtonsRadioReactiveFormsComponent implements OnInit { | ||
public myForm: FormGroup; | ||
|
||
constructor(private fb: FormBuilder) { | ||
this.createForm(); | ||
constructor(private formBuilder: FormBuilder) { | ||
} | ||
|
||
createForm() { | ||
this.myForm = this.fb.group({ | ||
myControl: ['Middle', Validators.required] | ||
ngOnInit() { | ||
this.myForm = this.formBuilder.group({ | ||
left: false, | ||
middle: true, | ||
right: false | ||
}); | ||
} | ||
} |