I'm trying to disable SCE in AngularJS. According to the documentation this is what needs to be done:
angular.module('myAppWithSceDisabledmyApp', []).config(function($sceProvider) {
// Completely disable SCE. For demonstration purposes only!
// Do not use in new projects.
$sceProvider.enabled(false);
});
This is my app.config.js:
angular.module('yapoApp').config(['$sceProvider', '$locationProvider', '$routeProvider', '$httpProvider',
function config($sceProvider, $locationProvider, $routeProvider, $httpProvider) {
// disable SCE completely (https://docs.angularjs.org/api/ng/service/$sce)
$sceProvider.enabled(false);
$locationProvider.hashPrefix('!');
$routeProvider.when('/actors', {
template: '<actor-list></actor-list>'
}).when('/actors/:actorId', {
template: '<actor-detail></actor-detail>'
}).when('/movies/', {
template: '<movie-list></movie-list>'
}).when('/movies/:movieId', {
template: '<movie-detail></movie-detail>'
}).otherwise('/'), {
template: '<br><br><br><br><h1> This is temp index</h1>'
};
}
]);
And I'm still getting an error:
[$interpolate:noconcat] Error while interpolating: /static/movies/{{ $ctrl.movie.id }}/sample/sample.mp4 Strict Contextual Escaping disallows interpolations that concatenate multiple expressions when a trusted value is required.
The html template causing the error:
<video width="{{ $ctrl.videoWidth }}px" controls>
<source ng-src="/static/movies/{{ $ctrl.movie.id }}/sample/sample.mp4">
Your browser does not support the video tag.
</video>
I feel like I'm missing some simple syntax error. Please help!
First you should check this, from doc:
Well, I don't think you need to disable SCE in this case, and also, for example, if you use
ngBindHtmlto render some HTML, AngularJS will throw an error unless the scope variable assigned tongBindHtmlis wrapped with$sce.trustAsHtml.But, let's back to the error, which one speaks for itself:
You just need to concatenate it in the right way, like this:
Hope it helps!!