【问题标题】:AngularJS, factory VisualForce Remoting errorAngularJS,工厂 VisualForce 远程处理错误
【发布时间】:2015-11-05 16:25:27
【问题描述】:

所以我试图创建一些东西,可以动态地从 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/

任何想法如何解决这个问题??

【问题讨论】:

  • 您的getDocuments(...) 调用是否返回任何<script> 标签?

标签: javascript angularjs angularjs-directive visualforce angularjs-factory


【解决方案1】:

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

我的一些语法被关闭了!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-16
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    • 1970-01-01
    • 1970-01-01
    • 2019-01-08
    相关资源
    最近更新 更多