我已經嘗試過這多次無濟於事。這裏是我的設置:角-UI路由器錯了
角:1.5.7
角UI路由器:0.3.1
這裏是我的文件:
/demo
/node_modules
(module files)
-index.html
-route1.html
-route1.list.html
-route2.html
-route2.list.html
以下是文件內容:
的index.html
<!doctype html>
<html data-ng-app="myapp">
<head>
<title>AngularJS ui-router Demo</title>
<link href="<path to bootstrap css file>" rel="stylesheet" />
<script src="<path to angular.min.js>"></script>
<script src="<path to angular-ui-router.min.js>"></script>
<script src="app.js"></script>
</head>
<body class="container">
<div class="navbar">
<div class="navbar-inner">
<a class="brand" href="#">Quick Start</a>
<ul class="nav">
<li><a ui-sref="route1">Route 1</a></li>
<li><a ui-sref="route2">Route 2</a></li>
</ul>
</div>
</div>
<div class="row">
<div class="span12">
<div class="well" ui-view></div>
</div>
</div>
<!-- angular script -->
<script>
var myapp = angular.module('myapp', ['ui-router']);
myapp.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('route1', {
url: '/route',
templateUrl: 'route1.html'
})
.state('route1.list', {
url: '/list',
templateUrl: 'route1.list.html',
controller: function($scope) {
$scope.items = ['A', 'List', 'of', 'Items'];
}
})
.state('route2', {
url: '/route2',
templateUrl: 'route2.html'
})
.state('route2.list', {
url: '/list',
templateUrl: 'route2.list.html',
controller: function($scope) {
$scope.things = ['A', 'Set', 'of', 'Things'];
}
})
})
</script>
</body>
</html>
的route1.html,route1.list.html,route2.html和route2.list.html與虛擬文本,沒有什麼特別的p標籤的所有簡單的H1標籤標題。
此代碼結構已從原始AngularJS ui-router示例進行了修改。
代碼似乎沒有任何問題。如果有人注意到任何錯誤或gremlin,請告知。
謝謝!
那麼不完全工作?什麼錯誤在控制檯中彈出(如果有的話)? –
@AlonEitan絕對沒有任何顯示爲錯誤。當我去檢查元素並查看控制檯時,我也沒有收到任何錯誤,因爲我注入了「ui-router」而不是「ui.router」。 (看下面的答案) –
是的,我知道,我發現答案之後,發現模塊名稱的問題:) –