diff --git a/demo/src/app/components/+buttons/buttons-section.list.ts b/demo/src/app/components/+buttons/buttons-section.list.ts index 33671bede8..cd6c815b6f 100644 --- a/demo/src/app/components/+buttons/buttons-section.list.ts +++ b/demo/src/app/components/+buttons/buttons-section.list.ts @@ -1,6 +1,7 @@ import { DemoButtonsBasicComponent } from './demos/basic/basic'; import { DemoButtonsCheckboxComponent } from './demos/checkbox/checkbox'; import { DemoButtonsRadioComponent } from './demos/radio/radio'; +import { DemoButtonsCheckboxReactiveFormsComponent } from './demos/checkbox-reactiveforms/checkbox-reactiveforms'; import { DemoButtonsRadioReactiveFormsComponent } from './demos/radio-reactiveforms/radio-reactiveforms'; import { DemoButtonsDisabledComponent } from './demos/disabled/disabled'; @@ -41,18 +42,30 @@ export const demoComponentContent: ContentSection[] = [ html: require('!!raw-loader?lang=markup!./demos/checkbox/checkbox.html'), outlet: DemoButtonsCheckboxComponent }, + { + title: 'Checkbox with Reactive Forms', + anchor: 'checkbox-reactiveforms"', + description: `
Checkbox buttons with ReactiveForms
`, + component: require('!!raw-loader?lang=typescript!./demos/checkbox-reactiveforms/checkbox-reactiveforms.ts'), + html: require('!!raw-loader?lang=markup!./demos/checkbox-reactiveforms/checkbox-reactiveforms.html'), + outlet: DemoButtonsCheckboxReactiveFormsComponent + }, { title: 'Radio & Uncheckable Radio', anchor: 'radio-button', - description: `Radio buttons with checked/unchecked states
`, + description: `Radio buttons with checked/unchecked states. Group can be created in two ways: using
+btnRadioGroup
directive or using the same ngModel
binding with several buttons (works only for
+template driven forms). Check the demo below for more info.
Checkbox buttons with ReactiveForms
`, + anchor: 'radio-reactiveforms', + description: `Radio buttons with ReactiveForms. Example below shows how to use radio buttons with reactive
+ forms. Please be aware that for reactive forms it's required to use btnRadioGroup
directive along with
+ btnRadio
's
{{myForm.value | json}}+ diff --git a/demo/src/app/components/+buttons/demos/checkbox-reactiveforms/checkbox-reactiveforms.ts b/demo/src/app/components/+buttons/demos/checkbox-reactiveforms/checkbox-reactiveforms.ts new file mode 100644 index 0000000000..62285d24c5 --- /dev/null +++ b/demo/src/app/components/+buttons/demos/checkbox-reactiveforms/checkbox-reactiveforms.ts @@ -0,0 +1,20 @@ +import { Component, OnInit } from '@angular/core'; +import { FormBuilder, FormGroup } from '@angular/forms'; + +@Component({ + selector: 'demo-buttons-checkbox-reactiveforms', + templateUrl: './checkbox-reactiveforms.html' +}) +export class DemoButtonsCheckboxReactiveFormsComponent implements OnInit { + myForm: FormGroup; + + constructor(private formBuilder: FormBuilder) {} + + ngOnInit() { + this.myForm = this.formBuilder.group({ + left: false, + middle: true, + right: false + }); + } +} diff --git a/demo/src/app/components/+buttons/demos/index.ts b/demo/src/app/components/+buttons/demos/index.ts index 0140d6908a..f1c79a2c9d 100644 --- a/demo/src/app/components/+buttons/demos/index.ts +++ b/demo/src/app/components/+buttons/demos/index.ts @@ -1,13 +1,15 @@ import { DemoButtonsBasicComponent } from './basic/basic'; import { DemoButtonsCheckboxComponent } from './checkbox/checkbox'; import { DemoButtonsRadioComponent } from './radio/radio'; -import { DemoButtonsRadioReactiveFormsComponent } from './radio-reactiveforms/radio-reactiveforms'; +import { DemoButtonsCheckboxReactiveFormsComponent } from './checkbox-reactiveforms/checkbox-reactiveforms'; import { DemoButtonsDisabledComponent } from './disabled/disabled'; +import { DemoButtonsRadioReactiveFormsComponent } from './radio-reactiveforms/radio-reactiveforms'; export const DEMO_COMPONENTS = [ DemoButtonsBasicComponent, DemoButtonsCheckboxComponent, DemoButtonsRadioComponent, + DemoButtonsCheckboxReactiveFormsComponent, DemoButtonsRadioReactiveFormsComponent, DemoButtonsDisabledComponent ]; diff --git a/demo/src/app/components/+buttons/demos/radio-reactiveforms/radio-reactiveforms.html b/demo/src/app/components/+buttons/demos/radio-reactiveforms/radio-reactiveforms.html index fe9f44f43d..386afbc50c 100644 --- a/demo/src/app/components/+buttons/demos/radio-reactiveforms/radio-reactiveforms.html +++ b/demo/src/app/components/+buttons/demos/radio-reactiveforms/radio-reactiveforms.html @@ -1,13 +1,10 @@ -
{{myForm.value | json}}-