0

所以我試圖創建一些動態從SalesForce中提取數據並將其顯示在我的角度應用程序中。我創建了下面的.factory功能:AngularJS,工廠VisualForce遠程處理錯誤

app.factory('getDocuments', ['$q','$rootScope', function($q, $rootScope){ 
    return function (inputString) { 
     var deferred = $q.defer(); 
     Visualforce.remoting.Manager.invokeAction(
      'FO_Manager.getDocuments', 
      inputString, 
      function(result, event){ 
       $rootScope.$apply(function(){ 
       if(event.status) { 
        deferred.resolve(result); 
       } else { 
        deferred.reject(event); 
       } 
      }) 
     }, 
     {buffer: true, escape: true, timeout: 30000} 
    ); 
    return deferred.promise; 
}}]); 

,如果我在控制器上運行它運行偉大的,當頁面加載getDocuments('a0N17000001NxjO').then(function(result){$scope.documents = result;}, function(error){$scope.error = result;});

當我嘗試我的動態指令

內運行,就會出現問題
app.directive('foSidenav',['getDocuments', function(getDocuments){ 
function linker($scope, element, attrs){ 
    $scope.selectDocType = function(id) 
    { 
     alert('docId updated'); 
     alert(id); 
     getDocuments(id).then(function(result){$scope.DocType = result;}, 
      function(error){$scope.error = result;}); 
    }; 
} 
return{ 

    restrict: 'E', 
    replace: true, 
    scope: { 

     info:'=', 
     DocType:'=' 
    }, 
    templateUrl:function(element,attr){ 

     return attr.url; 
    }, 
    link:linker 
};}]); 

現在的問題是,當我運行這段代碼的警報顯示正常,但後來我得到這個錯誤:

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/ .

任何想法如何解決這個問題?

+0

您的'getDocuments(...)'調用是否返回任何'