Non-angular problem 1.5 running with minified files

1

I have a project with angularjs 1.5 running on my machine debug mode, I was generating a release so I ran the gulp to minify the files and started the problems I made several adjustments and now I have this error:     "Error: [$ sce: unsafe] link $ sce / unsafe"

I do not know what to do because in the normal file it works and in the mined does not, does anyone know what error this is?

    
asked by anonymous 02.06.2016 / 21:55

2 answers

2

The problem is caused when you try to apply a text bind in html mode, that is, ng-bind-html without using the module ngSanitize , which is responsible for 'lapid', let's say that text for the same is displayed.

There are some "fixes" that you create a policy to circumvent this error so that you apply bind to "unsafe" mode. But the most correct way would be to initialize the module ngSanitize of the Angular itself in your application. It is a common initialization like any other module.

//Inclua o script como achar melhor, ex.:
<script src="//ajax.googleapis.com/ajax/libs/angularjs/X.Y.Z/angular-sanitize.js"></script>

and in your module boot:

angular.module('app', [
    //Seus outros módulos aqui
    'ngSanitize'
]);

Edited

As these options (and our conversation in the comments) did not solve the problem - which is quite strange - this would be the alternative fix I mentioned:

angular.module('gaxApp')
.filter('trust_html', ['$sce', function($sce){
    return function(text) {
        return $sce.trustAsHtml(text);
    };
}]);

Being used like this:

ng-bind-html="seucampo | trust_html"
    
02.06.2016 / 22:36
0

I was able to solve the problem that made ngSanitize not work. The problem happened because I was loading the login page without ngSanitize a after logging in I called another page that I did carry but the ng-apps had the same name and for some reason ngSanitize was not initialized, I separated everything right with other names and is running 100% now. Thanks for the help !!!

    
03.06.2016 / 16:45