【发布时间】:2017-07-20 18:16:46
【问题描述】:
我希望为我的 web 应用添加一个基本的 href。目前运行时一切正常:
- localhost:3000/#/登录
但我需要添加基本 href 或“charge” -> localhost:3000/charge/#/login
当前 index.html
<head>
<base href="charge/" />
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" ....
</head>
角线文件
function routerConfig($routeProvider, $locationProvider) {
$routeProvider
.when('/map', {
templateUrl: 'app/views/main/main.html',
controller: 'MainController',
controllerAs: 'mainCtrl'
})
.when('/login', {
templateUrl: 'app/views/login/login.html',
controller: 'LoginController',
controllerAs: 'loginCtrl'
})
.when('/list', {
templateUrl: 'app/views/list/list.html',
controller: 'ListController',
controllerAs: 'listCtrl'
})
.when('/reporting', {
templateUrl: 'app/views/reporting/reporting.html',
controller: 'ReportingController',
controllerAs: 'reportingCtrl'
})
.otherwise({
redirectTo: '/map'
});
// $locationProvider.html5Mode(true);
}
每当我使用 basehref 运行我的应用程序并导航到 localhost:3000/charge/#/login 时,基本上每个视图、控制器、Bower 组件和模块都找不到。我尝试编辑路由器,更改主应用程序文件夹的名称,但无法使其正常工作。我知道我错过了一些小东西,所以非常感谢任何帮助!
我的问题似乎与Base Href and Angular Routing and Views 非常相似,但老实说我无法弄清楚。
【问题讨论】:
标签: javascript angularjs angular-routing