Skip to content

Commit 2f4e76d

Browse files
committed
fix(select input, readme): Handle object options in select input
You can pass an object with key:value pairs for a select options instead only arrays. You also need formly-js#107
1 parent bf39c6f commit 2f4e76d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ _Example radio field_
246246
>The select field allows selection via dropdown using the select element.
247247
248248
##### options (array, required)
249-
>`options` is an array of options for the select form field to display. Each option should be an object with a `name`(string). You may optionally add a `group` to some or all of your options.
249+
>`options` it can be an array or an object:
250+
- an array of options for the select form field to display. Each option should be an object with a `name`(string). You may optionally add a `group` to some or all of your options.
251+
- an object with key an value pairs used in combination with ngOptions ([Example](http://jsbin.com/gikiji/3/edit?js,output)).
250252

251253
##### labelProp (string, optional)
252254
>`labelProp` is what is used for what is shown to the user. Defaults to `name`

src/types/select.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default ngModule => {
2121
},
2222
apiCheck: check => ({
2323
templateOptions: {
24-
options: check.arrayOf(check.object),
24+
options: check.oneOfType([check.arrayOf(check.object), check.objectOf(check.string)]),
2525
optionsAttr: check.string.optional,
2626
labelProp: check.string.optional,
2727
valueProp: check.string.optional,

0 commit comments

Comments
 (0)