AngularJS,工厂VisualForce远程处理错误

AngularJS, factory VisualForce Remoting error

本文关键字:处理 错误 程处理 工厂 VisualForce AngularJS      更新时间:2023-09-26

所以我试图创建一些东西,从SalesForce中动态提取数据,并将其显示在我的angular应用程序中。我创建了下面的.factory函数:

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
};}]);

现在的问题是,当我运行这个代码时,警报显示良好,但后来我得到了这个错误:

主线程上的同步XMLHttpRequest已被弃用,因为它会对最终用户的体验产生有害影响。有关更多帮助,请查看http://xhr.spec.whatwg.org/.

知道怎么绕过这个吗??

原来错误在其他地方,这个特定的错误并没有阻止脚本正确运行。

我的一些语法不正确!