Skip to content

Commit

Permalink
fix(demo): fix buttons reactive forms sample
Browse files Browse the repository at this point in the history
  • Loading branch information
valorkin committed Jun 19, 2017
1 parent 1eafa8c commit 325b510
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ let titleDoc = require('html-loader!markdown-loader!./docs/title.md');
</ng-sample-box>
<h2 routerLink="." fragment="radio-reactiveforms" id="radio-reactiveforms">Radio with ReactiveForms</h2>
<p>Radio buttons with ReactiveForms</p>
<p>Checkbox buttons with ReactiveForms</p>
<ng-sample-box [ts]="demos.radioReactiveForms.component" [html]="demos.radioReactiveForms.html">
<demo-buttons-radio-reactiveforms></demo-buttons-radio-reactiveforms>
</ng-sample-box>
Expand Down
9 changes: 2 additions & 7 deletions demo/src/app/components/+buttons/demos/checkbox/checkbox.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<pre class="card card-block card-header">
Model via JsonPipe: {{checkModel | json}}</pre>
<pre class="card card-block card-header">
Left: {{checkModel.left}}
Middle: {{checkModel.middle}}
Right: {{checkModel.right}}</pre>
<!--<pre class="card card-block card-header">Results: {{checkResults}}</pre>-->
<pre class="card card-block card-header">{{checkModel | json}}</pre>

<div class="btn-group">
<label class="btn btn-primary" [(ngModel)]="checkModel.left"
btnCheckbox>Left</label>
Expand Down
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>
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
});
}
}

0 comments on commit 325b510

Please sign in to comment.