每当滑块滑动时执行操作
Perform action whenever the slider slides
我在 codepen 中使用下面的 Angularjs 材料实现了一个简单的日期滑块。
http://codepen.io/helpme/pen/MaGpPa
.sliderdemoBasicUsage input[type="number"] {
text-align: center; }
我希望这个滑块在移动时执行一个简单的动作。例如,我希望在移动幻灯片时显示 window 警报 "Slider moved"。在访问文档 https://material.angularjs.org/latest/api/directive/mdSlider
后,我仍然不知道如何完成此操作
如果可能,如何做到这一点?
您可以观察特定组件 属性 或状态随 $scope 的变化。$watch:
我在这里修改了你的 Codepen:http://codepen.io/anon/pen/GpGdEM
.controller('AppCtrl', function($scope) {
$scope.month = 4;
$scope.$watch('month', function(val) {
// read the value of month and perform action
if (val === 9) alert('This is September');
});
});
我在 codepen 中使用下面的 Angularjs 材料实现了一个简单的日期滑块。 http://codepen.io/helpme/pen/MaGpPa
.sliderdemoBasicUsage input[type="number"] {
text-align: center; }
我希望这个滑块在移动时执行一个简单的动作。例如,我希望在移动幻灯片时显示 window 警报 "Slider moved"。在访问文档 https://material.angularjs.org/latest/api/directive/mdSlider
后,我仍然不知道如何完成此操作如果可能,如何做到这一点?
您可以观察特定组件 属性 或状态随 $scope 的变化。$watch:
我在这里修改了你的 Codepen:http://codepen.io/anon/pen/GpGdEM
.controller('AppCtrl', function($scope) {
$scope.month = 4;
$scope.$watch('month', function(val) {
// read the value of month and perform action
if (val === 9) alert('This is September');
});
});