kendo slider - 重置点击事件的值

时间:2015-10-29 04:52:21

标签: angularjs kendo-ui kendo-slider

有没有办法可以在改变后重置剑道滑块的值。 请参阅此示例代码:http://dojo.telerik.com/AKOhe/6

整个代码:



<!DOCTYPE html>
<html>
  <head>
    <title></title>
    <link rel="stylesheet" href="http://cdn.kendostatic.com/2015.2.624/styles/kendo.common-material.min.css" />
    <link rel="stylesheet" href="http://cdn.kendostatic.com/2015.2.624/styles/kendo.material.min.css" />

    <script src="http://cdn.kendostatic.com/2015.2.624/js/jquery.min.js"></script>
    <script src="http://cdn.kendostatic.com/2015.2.624/js/angular.min.js"></script>
    <script src="http://cdn.kendostatic.com/2015.2.624/js/kendo.all.min.js"></script>
  </head>
  <body>

    <div id="example" ng-app="KendoDemos">
      <div ng-controller="MyCtrl">
        <input k-ng-model="width" kendo-slider  />
      </div>
      <button k-ng-click="onClick()" />
    </div>

    <script>
      angular.module("KendoDemos", [ "kendo.directives" ])
      .controller("MyCtrl", function($scope){
        $scope.width = 3;
        $scope.onClick= function(){
        	$scope.width = 2;
        };
      })
    </script>


  </body>
</html>
&#13;
&#13;
&#13;

如何在重置按钮上重置kendo滑块的值?

提前致谢。

1 个答案:

答案 0 :(得分:0)

它不起作用,因为您将按钮放在控制器范围之外,您的代码已经正确。试试吧

<!DOCTYPE html>
<html>
  <head>
    <title></title>
    <link rel="stylesheet" href="http://cdn.kendostatic.com/2015.2.624/styles/kendo.common-material.min.css" />
    <link rel="stylesheet" href="http://cdn.kendostatic.com/2015.2.624/styles/kendo.material.min.css" />

    <script src="http://cdn.kendostatic.com/2015.2.624/js/jquery.min.js"></script>
    <script src="http://cdn.kendostatic.com/2015.2.624/js/angular.min.js"></script>
    <script src="http://cdn.kendostatic.com/2015.2.624/js/kendo.all.min.js"></script>
  </head>
  <body>

    <div id="example" ng-app="KendoDemos">
      <div ng-controller="MyCtrl" style="margin-bottom:20px;">
        <input k-ng-model="width" kendo-slider="slider"  />
        <button ng-click="onClick()"> reset</button>
      </div>
    </div>

    <script>
      angular.module("KendoDemos", [ "kendo.directives" ])
      .controller("MyCtrl", function($scope){
        $scope.width = 3;
        $scope.onClick= function(){
        	$scope.width = 2;
        };
      })
    </script>


  </body>
</html>