File tree Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -118,11 +118,13 @@ <h3>Works with ngRepeat</h3>
118118 < section id ="simple-usage " ng-controller ="StyleCtrl " dropdown-toggle >
119119 < h1 > Style usage</ h1 >
120120 < div >
121- < h3 > You can set different Bootstrap classes via the data-style attribute</ h3 >
122- < select selectpicker ="" data-style ="btn-{{color}} " ng-model ="color ">
123- < option value ="primary "> primary</ option >
124- < option value ="info "> info</ option >
125- < option value ="success "> success</ option >
121+ < h3 > Works with data-style</ h3 >
122+ < p > You can set different Bootstrap classes via the data-style attribute</ p >
123+ < select selectpicker ="" sp-theme ="btn-{{color}} " ng-model ="color ">
124+ < option value ="primary "> btn-primary</ option >
125+ < option value ="info "> btn-info</ option >
126+ < option value ="success "> btn-success</ option >
127+ < option value ="danger "> btn-danger</ option >
126128 </ select >
127129 </ div >
128130 </ section >
Original file line number Diff line number Diff line change @@ -177,6 +177,7 @@ angular.module('angular-bootstrap-select', [])
177177function selectpickerDirective ( $parse ) {
178178 return {
179179 restrict : 'A' ,
180+ priority : 1000 ,
180181 link : function ( scope , element , attrs ) {
181182 function refresh ( newVal ) {
182183 scope . $applyAsync ( function ( ) {
@@ -185,10 +186,14 @@ function selectpickerDirective($parse) {
185186 } ) ;
186187 }
187188
188- attrs . $observe ( 'style' , function ( val ) {
189- console . log ( val )
190- element . selectpicker ( 'setStyle' , val ) ;
191- } )
189+ attrs . $observe ( 'spTheme' , function ( val ) {
190+ scope . $applyAsync ( function ( ) {
191+ element . data ( 'selectpicker' ) . $button . removeClass ( function ( i , c ) {
192+ return ( c . match ( / ( ^ | \s ) ? b t n - \S + / g) || [ ] ) . join ( ' ' ) ;
193+ } ) ;
194+ element . selectpicker ( 'setStyle' , val ) ;
195+ } ) ;
196+ } ) ;
192197
193198 element . selectpicker ( $parse ( attrs . selectpicker ) ( ) ) ;
194199 element . selectpicker ( 'refresh' ) ;
You can’t perform that action at this time.
0 commit comments