angularjsbowermean-stackngsanitize

App breaks when I add ngSanitize as a dependency


When I add ngSanitize in my Angular app the system stops working.

Here is how I'm calling it:

angular.module('routings', ['ngSanitize']).controller('RoutingsController', ['$scope', '$sce',...
function($scope, $sce,...

angular-sanitize is already in my bower.json file and inside my index, so I don't know why this is not working.

EDIT: Here is how I call my JS files:

js: [
            'public/lib/angular/angular.js',
            'public/lib/angular-i18n/angular-locale_pt-br.js',
            'public/lib/angular-resource/angular-resource.js',
            'public/lib/angular-animate/angular-animate.js',
            'public/lib/angular-ui-router/release/angular-ui-router.js',
            'public/lib/angular-ui-utils/ui-utils.js',
            'public/lib/angular-bootstrap/ui-bootstrap-tpls.js',
            '//maps.googleapis.com/maps/api/js?libraries=geometry&language=ptbr&sensor=false',
            'public/lib/lodash/dist/lodash.min.js',
            'public/lib/angular-google-maps/dist/angular-google-maps.min.js',
            'public/lib/xlsx/lodash.min.js',
            'public/lib/xlsx/jszip.js',
            'public/lib/xlsx/xlsx.js',
            'public/lib/xlsx/xlsx-reader.js',
            'public/lib/file-saver/FileSaver.min.js',
            'public/lib/ngInfiniteScroll/build/ng-infinite-scroll.js',
            'public/lib/jspdf/dist/jspdf.debug.js',
            'public/lib/jspdf/plugins/addhtml.js',
            'public/lib/jspdf/plugins/html2canvas.js',
            'public/lib/angular-sanitize/angular-sanitize.js'
        ]

I have certified that my JS files are being loaded: enter image description here


Solution

  • I found an answer. There's nothing wrong with my code, but the project was not made by me, and I found a file called config.js in my public/ that have a list of all dependencies.

    So, I added ngSanitize in this file and all started to work.

    var applicationModuleVendorDependencies = ['ngResource', 'ngAnimate', 'ngSanitize', 'ui.router', 'ui.bootstrap', 'ui.utils', 'uiGmapgoogle-maps', 'infinite-scroll'];
    

    This is what happens when you start to work in a project that was not made by you and there's any documentation.