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

Commit d74b906

Browse files
committed
docs(cb-a11y): Building examples - Form controls
1 parent f3cc5bc commit d74b906

File tree

5 files changed

+52
-10
lines changed

5 files changed

+52
-10
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@
1818
Choose your favourite Angular 2 language:
1919
</a11y-radiobuttons>
2020

21+
<a11y-select [optionsModel]="selectOptions">Why are you interested in a11y?</a11y-select>
2122

22-
<div class="form-group">
23-
<label>Why are you interested in a11y?
24-
<select name="a11yreason" class="form-control">
25-
<option value="1">Curiosity</option>
26-
<option value="2">Increased userbase</option>
27-
<option value="3">Legal reasons</option>
28-
</select>
29-
</label>
30-
</div>
23+
24+
<!--<div class="form-group">-->
25+
<!--<label>Why are you interested in a11y?-->
26+
<!--<select class="form-control">-->
27+
<!--<option value="1">Curiosity</option>-->
28+
<!--<option value="2">Increased userbase</option>-->
29+
<!--<option value="3">Legal reasons</option>-->
30+
<!--</select>-->
31+
<!--</label>-->
32+
<!--</div>-->
3133

3234
<!--<label for="fortextArea">-->
3335
<!--Label for text area:-->

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,27 @@ import {A11yInputExplicit} from "./a11y-input-explicit.component";
55
import {A11yCheckboxes} from "./a11y-checkboxes.component";
66
import {A11yHelper} from "./services/a11y-helper.service";
77
import {A11yRadiobuttons} from "./a11y-radiobuttons.component";
8+
import {A11ySelect} from "./a11y-select.component";
89

910
@Component({
1011
selector: 'a11y-form-controls',
1112
templateUrl: './app/a11y-form-controls.component.html',
12-
directives: [CORE_DIRECTIVES, FORM_DIRECTIVES, A11yInput, A11yInputExplicit, A11yCheckboxes, A11yRadiobuttons]
13+
directives: [CORE_DIRECTIVES, FORM_DIRECTIVES, A11yInput, A11yInputExplicit,
14+
A11yCheckboxes, A11yRadiobuttons, A11ySelect]
1315
})
1416
export class A11yFormControls implements OnInit{
1517

1618
checkBoxes: any;
1719
radioButtons: any;
20+
selectOptions: any;
1821

1922
constructor(private _a11yHelper: A11yHelper){
2023
}
2124

2225
ngOnInit(){
2326
this.checkBoxes = this._a11yHelper.getCheckboxModel();
2427
this.radioButtons = this._a11yHelper.getRadiobuttonsModel();
28+
this.selectOptions = this._a11yHelper.getSelectOptions();
2529
}
2630

2731
submit(formValue: any):void{
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="form-group">
2+
<label><ng-content></ng-content>
3+
<select class="form-control">
4+
<option *ngFor="#option of optionsModel" [value]="option.value">{{option.name}}</option>
5+
</select>
6+
</label>
7+
</div>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {Input, Component} from "angular2/core";
2+
3+
@Component({
4+
selector: 'a11y-select',
5+
templateUrl: './app/a11y-select.component.html'
6+
})
7+
export class A11ySelect{
8+
9+
@Input()
10+
optionsModel: any
11+
12+
}

public/docs/_examples/cb-a11y/ts/app/services/a11y-helper.service.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ export class A11yHelper {
5555
];
5656
}
5757

58+
getSelectOptions(): any {
59+
return [
60+
{
61+
name: 'Curiosity',
62+
value: 0
63+
},
64+
{
65+
name: 'Increased userbase',
66+
value: 1
67+
},
68+
{
69+
name: 'Legal reasons',
70+
value: 2
71+
}
72+
];
73+
}
74+
5875
private randomGuidSnippet():string {
5976
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
6077
}

0 commit comments

Comments
 (0)