Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 06a5bb2

Browse files
committed
docs(cb-a11y): Building examples - Form controls
1 parent f83f094 commit 06a5bb2

File tree

4 files changed

+57
-9
lines changed

4 files changed

+57
-9
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<fieldset class="form-group row">
2+
<div class="col-xs-12">
3+
<legend><ng-content></ng-content></legend>
4+
<div *ngFor="#checkbox of checkboxModel" class="checkbox col-xs-12">
5+
<label>
6+
<input type="checkbox" [value]="checkbox.value" [name]="checkboxName">
7+
{{checkbox.name}}
8+
</label>
9+
</div>
10+
</div>
11+
</fieldset>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {Component, Input} from "angular2/core";
2+
3+
@Component({
4+
selector: 'a11y-checkboxes',
5+
templateUrl: './app/a11y-checkboxes.component.html'
6+
})
7+
export class A11yCheckboxes {
8+
9+
@Input()
10+
checkboxName: string;
11+
@Input()
12+
checkboxModel: any;
13+
14+
}

public/docs/_examples/cb-a11y/ts/app/a11y-form-controls.component.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33

44
<a11y-input>Label for input:</a11y-input>
55

6-
<div class="form-group">
7-
<label>Test
8-
<input class="form-control">
9-
</label>
10-
</div>
116

127
<div class="form-group">
138
<label>Test
149
<textarea class="form-control"></textarea>
1510
</label>
1611
</div>
1712

13+
<a11y-checkboxes [checkboxModel]="checkBoxes" [checkboxName]="'likes'">
14+
What do you like most about Angular 2?
15+
</a11y-checkboxes>
16+
17+
1818
<div class="form-group">
1919
<label for="a11yreason">Why are you interested in a11y?
2020
<select id="a11yreason" name="a11yreason" class="form-control">
@@ -25,7 +25,6 @@
2525
</label>
2626
</div>
2727

28-
2928
<label for="fortextArea">
3029
Label for text area:
3130
</label>

public/docs/_examples/cb-a11y/ts/app/a11y-form-controls.component.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
1-
import {Component} from "angular2/core";
1+
import {Component, OnInit} from "angular2/core";
22
import {CORE_DIRECTIVES, FORM_DIRECTIVES} from "angular2/common";
33
import {A11yInput} from "./a11y-input.component";
44
import {A11yInputExplicit} from "./a11y-input-explicit.component";
5+
import {A11yCheckboxes} from "./a11y-checkboxes.component";
56

67
@Component({
78
selector: 'a11y-form-controls',
89
templateUrl: './app/a11y-form-controls.component.html',
9-
directives: [CORE_DIRECTIVES, FORM_DIRECTIVES, A11yInput, A11yInputExplicit]
10+
directives: [CORE_DIRECTIVES, FORM_DIRECTIVES, A11yInput, A11yInputExplicit, A11yCheckboxes]
1011
})
11-
export class A11yFormControls {
12+
export class A11yFormControls implements OnInit{
13+
14+
checkBoxes: any;
15+
16+
ngOnInit(){
17+
this.checkBoxes = [
18+
{
19+
name: 'Template syntax',
20+
value: 0
21+
},
22+
{
23+
name: 'Observables',
24+
value: 1
25+
},
26+
{
27+
name: 'Components',
28+
value: 2
29+
},
30+
{
31+
name: 'Forms',
32+
value: 3
33+
}
34+
];
35+
}
1236

1337
submit(formValue: any):void{
1438
console.log(formValue)

0 commit comments

Comments
 (0)