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

Commit 5eb2073

Browse files
OskarPerssonKent C. Dodds
authored andcommitted
feat(select): Add notNull and nullDisplay properties (#111)
1 parent bf39c6f commit 5eb2073

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@ _Example radio field_
260260
##### optionsAttr (string, optional)
261261
>`optionsAttr` is what is used as the attribute ngOptions will be applied to. Defaults to `ng-options`
262262
263+
##### notNull (boolean, optional)
264+
>`notNull` whether to add an empty null option
265+
266+
##### nullDisplay (string, optional)
267+
>`nullDisplay` Null option label
268+
263269
##### ngOptions (string, optional)
264270
>If provided, this is used instead of the default `ng-options` giving you full control (and rendering the other options uncessisary.
265271

src/types/select.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
export default ngModule => {
22
ngModule.config(addSelectType);
33

4-
const template = `<select class="form-control" ng-model="model[options.key]"></select>`;
4+
const template = `<select class="form-control" ng-model="model[options.key]">
5+
<option ng-hide="to.notNull" value="">{{to.nullDisplay}}</option>
6+
</select>`;
57

68
function addSelectType(formlyConfigProvider) {
79
formlyConfigProvider.setType({
@@ -25,7 +27,9 @@ export default ngModule => {
2527
optionsAttr: check.string.optional,
2628
labelProp: check.string.optional,
2729
valueProp: check.string.optional,
28-
groupProp: check.string.optional
30+
groupProp: check.string.optional,
31+
notNull: check.boolean.optional,
32+
nullDisplay: check.string.optional
2933
}
3034
})
3135
});

0 commit comments

Comments
 (0)