William Kennedy
William Kennedy

Reputation: 143

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

Upvotes: 0

Views: 1075

Answers (2)

William Kennedy
William Kennedy

Reputation: 143

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.

Upvotes: 2

Chris Story
Chris Story

Reputation: 1197

I would be willing to guess that the ng sanitize file is not loaded on your html landing page where angular.js is loaded. See below

<script src="angular.js">
<script src="angular-sanitize.js">

Upvotes: 0

Related Questions