I`m new in AngularJS
我是AngularJS的新手
I`m getting this error:
我收到这个错误:
Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:modulerr] Failed to instantiate module ui.router due to:
Error: [$injector:nomod] Module 'ui.router' 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.
this is index.html file:
这是index.html文件:
<!doctype html>
<html ng-app="app">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Untitled</title>
<link rel="stylesheet" href="css/style.css">
<link rel="author" href="humans.txt">
</head>
<body ng-controller="FirstCtrl">
<input type="text" ng-model="first.greeting"/>
<div ng-class="first.greeting">{{first.greeting}}</div>
<script src="angular.js"></script>
<script src="app/app.js"></script>
<script src="js/main.js"></script>
</body>
</html>
and this is app.js file:
这是app.js文件:
var app = angular.module("app", ["ui.router"]).controller("FirstCtrl", function FirstCtrl(){
var first = this;
first.greeting = "First";
});
Please help me to solve this issue
请帮我解决这个问题
4 个解决方案
#1
10
You're not loading in the ui-router script, I don't know if you have it locally or using a cdn, you just need to add it in your index.html there
你没有加载ui-router脚本,我不知道你是在本地使用它还是使用cdn,你只需要在index.html中添加它
for example, by adding-
例如,加入─
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.15/angular-ui-router.min.js"></script>
in your index.html (this is a cdn link)
在你的index.html(这是一个cdn链接)
#2
0
<script src="angular.js"></script>
This is just the core angular library, you need to either download and host the latest angular ui router library or pull it in from a CDN
这只是核心角度库,您需要下载并托管最新的角度ui路由器库或从CDN中取出它
see here for more details: https://github.com/angular-ui/ui-router
有关详细信息,请参阅此处:https://github.com/angular-ui/ui-router
#3
0
Fixed by following steps:
通过以下步骤修复:
Installed angular-ui-router via npm
通过npm安装angular-ui-router
npm install angular-ui-router@0.2.18 --save
Then load the script in index.html (angular 1.5.0)
然后在index.html中加载脚本(角度1.5.0)
<script src="node_modules/angular/angular.js"></script>
<script src="node_modules/angular-ui-router/release/angular-ui-router.js"></script>
#4
0
Can be installed via nuget
可以通过nuget安装
PM > Install-Package Angular.UI.UI-Router
PM>安装包Angular.UI.UI-Router
#1
10
You're not loading in the ui-router script, I don't know if you have it locally or using a cdn, you just need to add it in your index.html there
你没有加载ui-router脚本,我不知道你是在本地使用它还是使用cdn,你只需要在index.html中添加它
for example, by adding-
例如,加入─
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.15/angular-ui-router.min.js"></script>
in your index.html (this is a cdn link)
在你的index.html(这是一个cdn链接)
#2
0
<script src="angular.js"></script>
This is just the core angular library, you need to either download and host the latest angular ui router library or pull it in from a CDN
这只是核心角度库,您需要下载并托管最新的角度ui路由器库或从CDN中取出它
see here for more details: https://github.com/angular-ui/ui-router
有关详细信息,请参阅此处:https://github.com/angular-ui/ui-router
#3
0
Fixed by following steps:
通过以下步骤修复:
Installed angular-ui-router via npm
通过npm安装angular-ui-router
npm install angular-ui-router@0.2.18 --save
Then load the script in index.html (angular 1.5.0)
然后在index.html中加载脚本(角度1.5.0)
<script src="node_modules/angular/angular.js"></script>
<script src="node_modules/angular-ui-router/release/angular-ui-router.js"></script>
#4
0
Can be installed via nuget
可以通过nuget安装
PM > Install-Package Angular.UI.UI-Router
PM>安装包Angular.UI.UI-Router