我用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