Skip to content
This repository was archived by the owner on Oct 5, 2019. It is now read-only.

Commit 934a33e

Browse files
committed
expose slider.relayout via scope event
1 parent d2357c9 commit 934a33e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

slider.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ angular.module('ui.bootstrap-slider', [])
2727
link: function ($scope, element, attrs, ngModelCtrl, $compile) {
2828
var ngModelDeregisterFn, ngDisabledDeregisterFn;
2929

30-
initSlider();
30+
var slider = initSlider();
3131

3232
function initSlider() {
3333
var options = {};
@@ -201,16 +201,21 @@ angular.module('ui.bootstrap-slider', [])
201201
slider.relayout();
202202
});
203203
}, true);
204+
205+
return slider;
204206
}
205207

206208

207209
var watchers = ['min', 'max', 'step', 'range', 'scale'];
208210
angular.forEach(watchers, function (prop) {
209211
$scope.$watch(prop, function () {
210-
initSlider();
211-
212+
slider = initSlider();
212213
});
213214
});
215+
216+
$scope.$on('slider:relayout', function() {
217+
slider.relayout();
218+
});
214219
}
215220
};
216221
}])

test.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122

123123
<label for="formatter_sufffix">Formatter suffix:</label>
124124
<input id="formatter_sufffix" type="text" ng-model="suffix" class="form-control">
125+
<button ng-click="$broadcast('slider:relayout')">Relayout</button>
125126
</p>
126127

127128
Slider with configurable tooltip<br>

0 commit comments

Comments
 (0)