Skip to content
This repository was archived by the owner on Apr 30, 2018. It is now read-only.

Commit 4dee7fb

Browse files
author
Kent C. Dodds
committed
Adding improved API to allow custom ngOptions support.
1 parent 9208f56 commit 4dee7fb

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 4.0.10
2+
3+
- Making an easier api for custom `ng-options` for `select`.
4+
15
# 4.0.9
26

37
- Allowing descriptions on all types

src/types/select.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<select class="form-control"
2+
ng-model="model[options.key]"
3+
ng-options="option[to.valueProp || 'value'] as option[to.labelProp || 'name'] group by option[to.groupProp || 'group'] for option in to.options">
4+
</select>

src/types/select.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ export default ngModule => {
77
name: 'select',
88
template: require('./select.html'),
99
wrapper: ['bootstrapLabel', 'bootstrapHasError'],
10+
defaultOptions(options) {
11+
if (options.templateOptions.ngOptions) {
12+
return {
13+
ngModelAttrs: {
14+
[options.templateOptions.ngOptions]: {
15+
value: 'ng-options'
16+
}
17+
}
18+
};
19+
}
20+
},
1021
apiCheck: {
1122
templateOptions: c.shape({
1223
options: c.arrayOf(c.object),

0 commit comments

Comments
 (0)