I'm using AngularJS 1.6.4, I get this error concerning $sce:
Error: [$sce:itype] http://errors.angularjs.org/1.6.4/$sce/itype?p0=html Trace de la pile : L/<@https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js:6:425 trustAs@https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js:155:46 [...]
Main Controller
(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);
I don't understand what means this error. Someone can explain me ? How can I fix it ?
$sce:itype
error happens when you are attempted to trust a non-string value in a content requiring a string.
In the success callback, the response
object is probably not HTML code. So it fails when trying to trust it as HTML using $sce
.
Inspect the response
object, there is probably a response.data
that contains your HTML code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With