1

DWR コールバックで「モデル」を変更しようとすると問題が発生します。

function mainCtrl($scope) {
     $scope.mymodel = "x";  // this is ok
     DWRService.searchForSomething(function(result){
           $scope.mymodel = result; // PROBLEM!!! it does not rerender the new value
     }
     $scope.mymodel = "y";  // this is also ok.
}

誰にもアイデアはありますか?

4

2 に答える 2

2

私は DWR にあまり詳しくありませんが、モデルの変更を囲むには $scope.$apply が必要だと思います。そのようです:

function mainCtrl($scope) {
   $scope.mymodel = "x";  // this is ok
   DWRService.searchForSomething(function(result){
       $scope.$apply(function() {
            $scope.mymodel = result; // PROBLEM!!! it does not rerender the new value
       });
   });
   $scope.mymodel = "y";  // this is also ok.
}
于 2013-09-07T06:28:00.460 に答える