我用ui-router
(州)爲我的路由:Angularjs客戶端路由與UI路由器
$urlRouterProvider.otherwise('/Home');
$stateProvider
.state('home', {
url: '/Home',
templateUrl: '/Home/Home',
controller: 'MainCtrl'
})
.state('posts', {
url: '/Posts',
templateUrl: '/Home/Posts',
controller: 'PostCtrl'
});
$locationProvider.html5Mode(true);
在HTML我有這樣的事情:
<html>
<head>
<base href="/" />
<!--render scripts -->
<title>My Angular App!</title>
</head>
<body ng-app="flapperNews" ngcloak>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<ul>
<li><a ui-sref="home">Home</a></li>
<li><a ui-sref="posts">Posts</a></li>
</ul>
<ui-view></ui-view>
</div>
</div>
</body>
</html>
當我用我的菜單鏈接(主頁,帖子)該應用程序工作正常,並根據需要更新我的觀點<ui-view></ui-view>
。當我第一次下載後使用地址欄將url更改爲localhost:port/Posts
時,該應用會刷新頁面。
請記住,我已將#從鏈接中刪除。
爲什麼角度不知道我的路線?
或者我該如何設置角度的客戶端菜單?
@PankajParkar,我試過了,菜單既一些變體效果很好。 我的地址欄導航問題。 – Dmitry