Angularjs 如何在角度范围滑块中添加事件。我使用ngchange,但它不起作用
如何在角度范围滑块值更改时触发事件并调用函数。ngchange不起作用。在这里,请查看以下代码:Angularjs 如何在角度范围滑块中添加事件。我使用ngchange,但它不起作用,angularjs,rangeslider,Angularjs,Rangeslider,如何在角度范围滑块值更改时触发事件并调用函数。ngchange不起作用。在这里,请查看以下代码: angular.module('myApp',['ui-rangeSlider'])) .controller('MyController',函数($scope){ $scope.rangeSlider={ 明普莱斯:10, 最高价格:100 } $scope.userMinPrice=50; $scope.userMaxPrice=80; $scope.$watch('userMinPrice'
angular.module('myApp',['ui-rangeSlider']))
.controller('MyController',函数($scope){
$scope.rangeSlider={
明普莱斯:10,
最高价格:100
}
$scope.userMinPrice=50;
$scope.userMaxPrice=80;
$scope.$watch('userMinPrice',函数(newVal,oldVal){
if(newVal!==oldVal){
$scope.message='userMinPrice已从'+oldVal+'更改为'+newVal;
//你想在这里干什么都行。
}
});
$scope.$watch('userMaxPrice',函数(newVal,oldVal){
if(newVal!==oldVal){
$scope.message='userMaxPrice已从'+oldVal+'更改为'+newVal;;
//你想在这里干什么都行。
}
});
});代码>
{{message}}
我得到了解决方案。用在把手上
<div range-slider min="minPrice" max="maxPrice" modelmin="userMinPrice" model-max="userMaxPrice" step="5" ng-model="selectedPrice" ng-change="price()"></div>
这将对您有所帮助
<div range-slider min="minPrice" max="maxPrice" model-min="userMinPrice" model-max="userMaxPrice" step="5" ng-model="selectedPrice" filter="currency" on-handle-up="choosePrice()"></div>
如果您正在使用这款手表并查看文档,我认为“范围滑块”不支持ng model
或ng change
,那么您可以添加手表,如果您需要,我可以提供演示代码。是的。我需要演示代码。你能上传它吗?看看我贴的答案。是的,这也可以达到目的。
<div
range-slider min="0"
max="100"
model-max="demo7.valueB"
pin-handle="min"
on-handle-up="choosePrice(demo7.valueB)">
</div>
$scope.choosePrice=function(val)
{
console.log(val);
}