Mantvydas Ozerenskis Mantvydas Ozerenskis - 21 days ago 13
AngularJS Question

Kendo uploader with angular doesn't update scope

Why Kendo Uploader with angular doesn't apply changes in UI?

Let's say on select event (same on success):

$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();
}


Dojo eg.: http://dojo.telerik.com/UpuGoK

If I run scope apply function then it works, but I don't like this solution.

Answer

Unfortunately, you will have to use $scope.$apply because the event is triggered without Angular knowing about it. This Kendo Upload component seems to be a jQuery thing that was made somewhat compatible with Angular.

The best thing you can do is to create a function that you can use all around:

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

$scope.onSelect = kendoEvent($scope, function (event) {
    ...
});
Comments