【问题标题】:Kendo uploader with angular doesn't update scope带有角度的剑道上传不会更新范围
【发布时间】:2016-11-13 16:43:24
【问题描述】:

为什么带有 Angular 的 Kendo Uploader 不会在 UI 中应用更改?

假设选择事件(成功时相同):

$scope.onSelect = function(e) {
   var message = $.map(e.files, function(file) { return file.name; }).join(", ");
   kendoConsole.log("event :: select (" + message + ")");
   $scope.uiUpdate = "doesn't work";
   //$scope.$apply();
}

道场 例如:http://dojo.telerik.com/UpuGoK

如果我运行范围应用功能,那么它可以工作,但我不喜欢这个解决方案。

【问题讨论】:

    标签: angularjs kendo-ui telerik kendo-upload


    【解决方案1】:

    不幸的是,您将不得不使用 $scope.$apply 因为事件是在 Angular 不知道的情况下触发的。这个 Kendo Upload 组件似乎是一个 jQuery 的东西,它与 Angular 在某种程度上兼容。

    你能做的最好的事情就是创建一个你可以到处使用的函数:

    function kendoEvent($scope, eventHandler) {
        return $scope.$apply(eventHandler);
    }
    
    $scope.onSelect = kendoEvent($scope, function (event) {
        ...
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-28
      相关资源
      最近更新 更多