我试图在我的应用程序使用angular-ui-router
,但在导入
Error: [$injector:modulerr] Failed to instantiate module uiRouter due to:
Error: [$injector:nomod] Module 'uiRouter' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
这里的时候,我有问题是我main.js
import angular from 'angular';
import uiRouter from 'angular-ui-router';
(function() {
function config($locationProvider, $stateProvider) {
$locationProvider
.html5Mode({
enabled: true,
requireBase: false
});
}
angular
.module('myApp', ['uiRouter'])
.config(config);
})();
我index.html
文件的应用程序宣布 <html lang="en" ng-app="myApp">
我已经通过NPM安装两个包
[email protected] /Users/.../myApp
├── [email protected]
├─┬ [email protected]
│ └── @uirouter/[email protected]
不知道,如果是相关的,但也宣告它在package.json
"dependencies": {
"angular": "^1.6.5",
"angular-ui-router": "^1.0.3",
在过去,我一直通过<script>
标签进口角图书馆index.html
所以我不熟悉进口的包。
另外,我读的是ui-router
作为范围包提供:https://ui-router.github.io/blog/uirouter-scoped-packages/但不知道它是否与此处相关(我也导入了此链接中描述的包,但似乎没有帮助)。
问题为什么不是angular-ui-router
被识别?
你可以提供一个你的代码plunker。你确定包含angular-ui-router吗 – user93
你是否在脚本标签中包含了'angular-ui-router'在你的html里面? –