Skip to content

Commit 7f2d3b7

Browse files
committed
fix(selectpicker) change value for track by ngOptions only
1 parent d162d28 commit 7f2d3b7

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

demo/index.html

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ <h3>Works with ngDisable</h3>
6969
<div>Enabled/Disabled <input type="checkbox" ng-model="selectWithNgDisabled"></div>
7070

7171
<div>
72-
<select id="selectVisible" ng-disabled="selectWithNgDisabled" selectpicker="{}" ng-model="model">
72+
<select id="selectVisible" ng-disabled="selectWithNgDisabled" selectpicker ng-model="model">
7373
<option value="">Select one</option>
7474
<option>Mustard</option>
7575
<option>Ketchup</option>
@@ -117,6 +117,16 @@ <h3>Works with ngRepeat</h3>
117117
<!-- Styles -->
118118
<section id="simple-usage" ng-controller="StyleCtrl" dropdown-toggle>
119119
<h1>Style usage</h1>
120+
<div>
121+
<h3>Works with selectpicker style option</h3>
122+
<p>You can set different Bootstrap classes via the selectpicker style option</p>
123+
<select selectpicker="{style:'btn-info'}">
124+
<option value="">Select one</option>
125+
<option>Mustard</option>
126+
<option>Ketchup</option>
127+
<option>Relish</option>
128+
</select>
129+
</div>
120130
<div>
121131
<h3>Works with data-style</h3>
122132
<p>You can set different Bootstrap classes via the data-style attribute</p>
@@ -125,6 +135,19 @@ <h3>Works with data-style</h3>
125135
<option value="info">btn-info</option>
126136
<option value="success">btn-success</option>
127137
<option value="danger">btn-danger</option>
138+
<option value="warning">btn-warning</option>
139+
<option value="inverse">btn-inverse</option>
140+
</select>
141+
</div>
142+
<div>
143+
<h3>Works with option data-content</h3>
144+
<select selectpicker="" ng-model="color">
145+
<option data-content="<span class='label label-primary'>btn-primary</span>" value="primary">btn-primary</option>
146+
<option data-content="<span class='label label-info'>btn-info</span>" value="info">btn-info</option>
147+
<option data-content="<span class='label label-success'>btn-success</span>" value="success">btn-success</option>
148+
<option data-content="<span class='label label-danger'>btn-danger</span>" value="danger">btn-danger</option>
149+
<option data-content="<span class='label label-warning'>btn-warning</span>" value="warning">btn-warning</option>
150+
<option data-content="<span class='label label-inverse'>btn-inverse</span>" value="inverse">btn-inverse</option>
128151
</select>
129152
</div>
130153
</section>

src/angular-bootstrap-select.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ function selectpickerDirective($parse) {
181181
link: function (scope, element, attrs) {
182182
function refresh(newVal) {
183183
scope.$applyAsync(function () {
184-
if (!attrs.ngOptions || /track by/.test(attrs.ngOptions)) element.val(newVal);
184+
if (attrs.ngOptions && /track by/.test(attrs.ngOptions)) element.val(newVal);
185185
element.selectpicker('refresh');
186186
});
187187
}

0 commit comments

Comments
 (0)