This repository was archived by the owner on Jan 22, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 1
1
import template from './select.html' ;
2
+ import { ngModelAttrsManipulator } from './../../helpers' ;
2
3
3
4
export default ( formlyConfigProvider ) => {
4
5
formlyConfigProvider . setType ( {
@@ -13,9 +14,6 @@ export default (formlyConfigProvider) => {
13
14
disabled : {
14
15
bound : 'ng-disabled'
15
16
} ,
16
- multiple : {
17
- bound : 'multiple'
18
- } ,
19
17
onClose : {
20
18
bound : 'md-on-close'
21
19
} ,
@@ -36,4 +34,11 @@ export default (formlyConfigProvider) => {
36
34
}
37
35
} )
38
36
} ) ;
37
+
38
+ formlyConfigProvider . templateManipulators . preWrapper . push ( ( tpl , options ) => {
39
+ const to = options . templateOptions || { } ;
40
+ // adds multiple only when:
41
+ // templateOptions.multiple equals true
42
+ return to . multiple === true ? ngModelAttrsManipulator ( tpl , options , 'multiple' ) : tpl ;
43
+ } ) ;
39
44
} ;
Original file line number Diff line number Diff line change @@ -101,6 +101,15 @@ describe('formlyMaterial - select type', () => {
101
101
expect ( element . attr ( 'multiple' ) ) . toBeDefined ( ) ;
102
102
} ) ;
103
103
104
+ it ( 'should not add multiple directive when does not equal true' , ( ) => {
105
+ compile ( {
106
+ templateOptions : {
107
+ multiple : false
108
+ }
109
+ } ) ;
110
+ expect ( element . attr ( 'multiple' ) ) . toBeUndefined ( ) ;
111
+ } ) ;
112
+
104
113
it ( 'should be able to bind md-on-close' , ( ) => {
105
114
compile ( ) ;
106
115
expect ( element . attr ( 'md-on-close' ) ) . toBe ( `options.templateOptions['onClose']` ) ;
You can’t perform that action at this time.
0 commit comments