angular-sanitize:未捕获错误:Angular 1.2.1上的[$ injector:unpr]

时间:2013-12-06 18:34:15

标签: angularjs

我在angular-sanitize#1.2.3中使用Yeoman Generator安装了Angular 1.2.1

index.html

...
<!-- build:js scripts/modules.js -->
  <script src="bower_components/angularjs-geolocation/src/geolocation.js"></script>
  <script src="bower_components/angular-cookies/angular-cookies.js"></script>
  <script src="bower_components/angular-route/angular-route.js"></script>
  <script src="bower_components/angular-translate/angular-translate.js"></script>

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

  <script src="bower_components/ngprogress/build/ngProgress.js"></script>
  <script src="bower_components/ngstorage/ngStorage.js"></script>
<!-- endbuild -->
...

app.js:

...
angular.module('angularGeolocationApp', [
  'ngCookies',
  'ngRoute',
  'geolocation',
  'pascalprecht.translate',
  'ngProgress',
  'ngStorage',
  'ngSanitize'
])
...

如果没有注入$sanitize,我会得到:

enter image description here

我错过了什么?

2 个答案:

答案 0 :(得分:3)

angular-sanitize v1.2.3与AngularJS v1.2.1不兼容 最新版本的$ sanitize(1.2.3)现在使用与$compile相同的机制来验证uris,它使用新的私有服务$$ sanitizeUri,它只是AngularJS v1.2.3及更高版本的一部分。有关详细信息,请参阅此commit

要解决,请安装angular-sanitize v1.2.1或将AngularJS升级到1.2.3

答案 1 :(得分:0)

它看起来你拥有必须运行的一切,无一例外。我唯一可以建议的是检查您使用angular.module('angularGeolocationApp'...)的其他任何地方,以确保您不会意外地覆盖依赖项。只需确保只有一个实例定义了第二个参数。

相关问题