【发布时间】:2015-08-18 19:42:58
【问题描述】:
我正在为我的应用程序使用 Angular
我想从 url 中删除 # 所以我按照SO answer 中的建议添加了以下行
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
在 index.html 中,我还按照建议添加了以下代码 here
<head>
<base href="/">
</head>
当我从家导航到页面时一切正常,但是当我复制 url 并在新选项卡中打开它时,它会抛出 404 error
示例
当我启动应用程序时,它正在打开http://localhost:portno/home。
刷新页面时,出现 404 错误。
我应该进行哪些其他配置?
我的代码结构如下
.state('tab.home', {
url: '/home',
views: {
'tab-home': {
templateUrl: 'templates/tab-home.html',
controller: 'templeHome'
}
}
})
.state('tab.list', {
url: '/list',
views: {
'tab-home': {
templateUrl: 'templates/list.html',
controller: 'templeList'
}
}
})
【问题讨论】:
-
我必须试试这个。但我无法得到明确的解决方案。如何克服这个问题
标签: angularjs ionic-framework angular-ui-router