例如,如果我尝试访问本地主机:8080,我的AngularJS应用程序正在运行,我正在重定向到http://localhost:8080/#/home,我在网址中间出现了一个奇怪的#。我不明白这个#来自哪里,但我怀疑它与我在$ stateProvider中定义的URL有关。
这里是$ stateProvider代码:
//STATE HANDLER
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
app.config([
'$stateProvider',
'$urlRouterProvider',
function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('newAlarm', {
url: '/newAlarm',
views: {
'': {templateUrl: '/templates/newAlarmPage.html'},
'[email protected]':{templateUrl: '/templates/header.html'},
'[email protected]':{templateUrl: '/templates/newAlarmForm.html'}
},
controller: 'NewScheduleCtrl'
})
//to be changed
.state('home', {
url: '/home',
views: {
'': {templateUrl: '/templates/homePage.html'},
'[email protected]':{templateUrl: '/templates/header.html'}
},
controller: ''
});
//end of to be changed
$urlRouterProvider.otherwise('home');
}]);
有什么想法?
看看http://stackoverflow.com/questions/7729580/how-can-i-use-urls-in-a -single-page-application然后http://stackoverflow.com/questions/14771091/removing-the-hashtag-from-angularjs-urls-symbol关于如何删除它 – br3w5