Javascript 如何修复AngularJS 1.6中的[$sce:itype]错误?
我使用的是AngularJS 1.6.4,我得到一个关于$sce的错误: 错误:[$sce:itype] $sce/itype?p0=html跟踪数据 :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) { '
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);