3

I am trying to use angular-sanitize in angularJS.

I require angular-sanitize and inject it in my module.

But i get the following errors:

Uncaught TypeError: f.module(...).provider(...).info is not a function

Uncaught Error: [$injector:modulerr]

app.js

const angular_sanitize = require('angular-sanitize/angular-sanitize.min.js');  

var app = angular
  .module('myApp', ['ngSanitize'])

It works if i am using a script in index.html, but i want it to work as a module dependency instead.

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular-sanitize.min.js"></script>
Community
  • 1
  • 1
user6086008
  • 101
  • 3
  • 14

2 Answers2

6

Had the same issue, not sure if the same fix but might help.. so.. in bower.json I had "angular-sanitize": "^1.5.5" and on bower install it pulled the latest version 1.6.4 which has breaking changes for my installed angular version 1.5.9.. Try to install the ng-sanitize version that works for your build

Teddy
  • 61
  • 2
1

if you are loading the resource from a local folder (static resource) please check if the path in the below statement (modified) is correct and the folder and the file exists.

require('./angular-sanitize/angular-sanitize.min'); 

otherwise if you are loading from a CDN resource as you are in your HTML you might have to configure your requirejs config object and map it to the CDN. The post below-

Loading Bootstrap from CDN with Require.js

Community
  • 1
  • 1
  • i think the path is correct. Im also loading other modules from the same local folder, and they work fine. I have also tried injecting 'angular.sanitize' instead of 'ngSanitize', still same error. – user6086008 Mar 21 '17 at 13:41
  • could you may be create a fiddle with your code which produces the error? it will be easier to investigate. thanks – Parikshit Bhagawati Mar 22 '17 at 08:34