我使用ui-router
(状态)作为路由:
$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
时,应用程序会刷新页面。
请记住,我从链接中删除了#。
为什么角不知道我的路线?
或者如何设置带有角度的客户端菜单?
发布于 2016-02-02 05:33:04
Angular知道您的路线,但是您的map服务器可能认为他需要在地图上显示index.html
页面posts
。
尝试将html5Mode设置为false,并查看是否仍然发生此链接,并查看有关Hashbang and HTML5 modes
的部分
尤其是最后一行requires server-side configuration: Yes
https://stackoverflow.com/questions/35154878
复制