Javascript 使用breezeJs和angular

Javascript 使用breezeJs和angular,javascript,asp.net-mvc,angularjs,breeze,Javascript,Asp.net Mvc,Angularjs,Breeze,我们目前正在使用breeze js和angular 每次调用服务器时,都必须添加$scope.$apply $scope.SelectSection = function () { var id = $scope.SectionId; //SectionId dataContext.getCategoriesBySectionId(id).then(function(data) { $scope.Categories =

我们目前正在使用breeze js和angular

每次调用服务器时,都必须添加$scope.$apply

  $scope.SelectSection = function () {
        var id = $scope.SectionId;
        //SectionId
        dataContext.getCategoriesBySectionId(id).then(function(data) {
            $scope.Categories = data.results;
            $scope.$apply()
        });
    }
在我搜索了breeze网站之后,我发现我们可以使用angular$http服务作为breeze的“Ajax实现”,这将使我们通过添加以下代码摆脱$scope.$apply()

angular.module('app').run(['$http', function ($http) {
    var ajax = breeze.config.initializeAdapterInstance('ajax', 'angular');
    ajax.setHttp($http); // use the $http instance that Angular injected into your app.
}]);
但不幸的是,代码在超出$scope的情况下仍然不能正常工作。$apply()

有人有什么建议吗???谢谢你

你可以看看这个,它使用了@PSL提到的。根本不使用
$scope.$apply

您尝试过使用吗?