Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何修复AngularJS 1.6中的[$sce:itype]错误?_Javascript_Angularjs_Http - Fatal编程技术网

Javascript 如何修复AngularJS 1.6中的[$sce:itype]错误?

Javascript 如何修复AngularJS 1.6中的[$sce:itype]错误?,javascript,angularjs,http,Javascript,Angularjs,Http,我使用的是AngularJS 1.6.4,我得到一个关于$sce的错误: 错误:[$sce:itype] $sce/itype?p0=html跟踪数据 : L/$sce:itype当您试图信任需要字符串的内容中的非字符串值时,会发生错误 在成功回调中,响应对象可能不是HTML代码。因此,当试图使用$sce将其信任为HTML时,它失败了 检查response对象,可能有response.data包含您的HTML代码。请发布您的response (function(angular) { '

我使用的是AngularJS 1.6.4,我得到一个关于$sce的错误:

错误:[$sce:itype] $sce/itype?p0=html跟踪数据 :
L/
$sce:itype
当您试图信任需要字符串的内容中的非字符串值时,会发生错误


在成功回调中,
响应
对象可能不是HTML代码。因此,当试图使用
$sce
将其信任为HTML时,它失败了


检查
response
对象,可能有
response.data
包含您的HTML代码。

请发布您的
response
(function(angular) {
    'use strict';
    angular.module('fooModule')
    .controller('MainCtrl', ['$scope', '$q', '$http', '$sce', function ($scope, $q, $http, $sce){
           ...
           $q.all([
            ...
        ]).then(function(responses) {
             $scope.send = function(){                                                           
                var data = {
                       ...
                    };

                    $http({
                        url: 'file.php',
                        method: "POST",
                        data: $.param(data),
                        headers: {'Content-Type': 'application/x-www-form-urlencoded'}
                    }).then(function successCallback(response) {
                        $scope.dataResponse = $sce.trustAsHtml(response);
                    }, function errorCallback(response) {
                        console.dir(response);
                    });
                }

            };
        });
           ...
     }]);
})(window.angular);