0

如果我使用ng-strict-di我的 Angular 应用程序并使用该ngRoute模块,我会收到错误消息:

[Error] Error: [$injector:modulerr] http://errors.angularjs.org/1.4.0-rc.0/$injector/modulerr?p0=epoiApp&p1=%5B%24injector%3Astrictdi%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.4.0-rc.0%2F%24injector%2Fstrictdi%3Fp0%3Dfunction(%2524routeProvider)%0Ahttps%3A%2F%2Fcode.angularjs.org%2F1.4.0-rc.0%2Fangular.min.js%3A6%3A426%0A%24%24annotate%40https%3A%2F%2Fcode.angularjs.org%2F1.4.0-rc.0%2Fangular.min.js%3A182%3A482%0Ae%40https%3A%2F%2Fcode.angularjs.org%2F1.4.0-rc.0%2Fangular.min.js%3A37%3A533%0Ad%40https%3A%2F%2Fcode.angularjs.org%2F1.4.0-rc.0%2Fangular.min.js%3A36%3A238%0Ahttps%3A%2F%2Fcode.angularjs.org%2F1.4.0-rc.0%2Fangular.min.js%3A36%3A358%0An%40https%3A%2F%2Fcode.angularjs.org%2F1.4.0-rc.0%2Fangular.min.js%3A7%3A306%0Ah%40https%3A%2F%2Fcode.angularjs.org%2F1.4.0-rc.0%2Fangular.min.js%3A36%3A135%0A%24a%40https%3A%2F%2Fcode.angularjs.org%2F1.4.0-rc.0%2Fangular.min.js%3A39%3A417%0Ad%40https%3A%2F%2Fcode.angularjs.org%2F1.4.0-rc.0%2Fangular.min.js%3A18%3A383%0Auc%40https%3A%2F%2Fcode.angularjs.org%2F1.4.0-rc.0%2Fangular.min.js%3A19%3A180%0AUd%40https%3A%2F%2Fcode.angularjs.org%2F1.4.0-rc.0%2Fangular.min.js%3A18%3A2%0Ahttps%3A%2F%2Fcode.angularjs.org%2F1.4.0-rc.0%2Fangular.min.js%3A285%3A431%0Afire%40file%3A%2F%2F%2FVolumes%2FMacintosh%2520HD%2FUsers%2FdeLac%2Fsiti%2Fepoi%2FePOI%2Fassets%2Flibs%2Fjquery.js%3A3143%3A35%0AfireWith%40file%3A%2F%2F%2FVolumes%2FMacintosh%2520HD%2FUsers%2FdeLac%2Fsiti%2Fepoi%2FePOI%2Fassets%2Flibs%2Fjquery.js%3A3255%3A11%0Aready%40file%3A%2F%2F%2FVolumes%2FMacintosh%2520HD%2FUsers%2FdeLac%2Fsiti%2Fepoi%2FePOI%2Fassets%2Flibs%2Fjquery.js%3A3467%3A24%0Acompleted%40file%3A%2F%2F%2FVolumes%2FMacintosh%2520HD%2FUsers%2FdeLac%2Fsiti%2Fepoi%2FePOI%2Fassets%2Flibs%2Fjquery.js%3A3498%3A15
    (anonymous function) (angular.min.js, line 37)
    n (angular.min.js, line 7)
    h (angular.min.js, line 36)
    $a (angular.min.js, line 39)
    d (angular.min.js, line 18)
    uc (angular.min.js, line 19)
    Ud (angular.min.js, line 18)
    (anonymous function) (angular.min.js, line 285)
    fire (jquery.js, line 3143)
    fireWith (jquery.js, line 3255)
    ready (jquery.js, line 3467)
    completed (jquery.js, line 3498)

这对我来说很奇怪,因为ngRoute它是 Angular 的官方模块,不是吗?有没有办法仍然一起使用它们?

我已经包含了 angular-route.min.js

<script src="https://code.angularjs.org/1.4.0-rc.0/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.0-rc.0/angular-route.min.js"></script> 
4

2 回答 2

0

粘贴了错误并得到了确切的错误文本

由于以下原因无法实例化模块 epoiApp:[$injector:strictdi] http://errors.angularjs.org/1.4.0-rc.0/$injector/strictdi...) https://code.angularjs.org/ 1.4.0-rc.0/angular.min.js:6:426

您应该包含 ng-route (angular-route.min.js) 的缩小版本以摆脱此错误。

有很多方法可以使代码缩小安全,您正在使用 strict-di,ng-route 可能正在使用 ng-annotate。每个库开发人员可能会使用不同的方法来确保代码压缩安全。最终应该实现具有非破坏性缩小代码的目标。

于 2015-04-17T14:20:49.053 回答
0

您必须在注册应用程序时注入此模块。

它没有附带 angular.js 文件。ngRouteangular-route.js文件中定义

angular.module('app', ['ngRoute']);

为此,您必须先加载angular-route.js

角路由.js

于 2015-04-17T13:49:52.523 回答