如何使用AngularJSUI路由器?
How to use AngularJS UI Router?
我正在尝试使用 AngularJS UI 路由器加载视图 1 和视图 2,但它们没有加载到 index.html 页面中。你能帮忙吗?
This is the link to whole project in Plunker
下面还有 index.html 页面代码:
<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8" />
<title>AngularJS Routing</title>
<script data-require="angular.js@*" data-semver="2.0.0" src="https://code.angularjs.org/2.0.0-beta.6/angular2.min.js"></script>
<script data-require="ui-router@*" data-semver="1.0.0-alpha.5" src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/1.0.0-alpha.5/angular-ui-router.js"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<ul class="menu">
<li>
<a ui-sref="view1">view1</a>
</li>
<li>
<a ui-sref="view2">view2</a>
</li>
<li>
<a ui-sref="index">Home</a>
</li>
</ul>
<div>Below you should see the partial view :) ... </div>
<div ng-view="">
<p>ng-view should be loading data from about.html right here but it's not working</p>
</div>
<script src="app.js"></script>
<script src="controllers.js"></script>
</body>
</html>
应该是ui-view
而不是ng-view
(angularngRoute
路由api用这个)
我正在尝试使用 AngularJS UI 路由器加载视图 1 和视图 2,但它们没有加载到 index.html 页面中。你能帮忙吗?
This is the link to whole project in Plunker
下面还有 index.html 页面代码:
<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8" />
<title>AngularJS Routing</title>
<script data-require="angular.js@*" data-semver="2.0.0" src="https://code.angularjs.org/2.0.0-beta.6/angular2.min.js"></script>
<script data-require="ui-router@*" data-semver="1.0.0-alpha.5" src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/1.0.0-alpha.5/angular-ui-router.js"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<ul class="menu">
<li>
<a ui-sref="view1">view1</a>
</li>
<li>
<a ui-sref="view2">view2</a>
</li>
<li>
<a ui-sref="index">Home</a>
</li>
</ul>
<div>Below you should see the partial view :) ... </div>
<div ng-view="">
<p>ng-view should be loading data from about.html right here but it's not working</p>
</div>
<script src="app.js"></script>
<script src="controllers.js"></script>
</body>
</html>
应该是ui-view
而不是ng-view
(angularngRoute
路由api用这个)