我正在尝试使用
angularjs中的html5Mode(true)删除url的index.html,这是代码:
angular.module('myApp', [
'ngRoute',
'myApp.filters',
'myApp.services',
'myApp.directives',
'myApp.controllers'
]).
config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider.when('/home', {templateUrl: 'views/home.html'});
$routeProvider.when('/about', {templateUrl: 'views/about.html'});
$routeProvider.otherwise({redirectTo: '/'});
}]);
如果我不写$locationProvider.html5Mode(true);网址显示:
localhost:(port)/MyApplication/index.html
如果我写$locationProvider.html5Mode(true);网址显示:
localhost:(port)
MyApplication已删除网址.
我想要网址显示:
localhost:(port)/MyApplication/
我做错了什么?有什么问题?
更新:
应该如何显示我的< a>标签?现在我有:
当我点击链接时,网址显示:
localhost:(port)/MyApplication/index.html#/about
我迷失了.
提前致谢!