angularjs html5模式,在angularjs中使用html5Mode的问题

我正在尝试使用

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>标签?现在我有:

About>

当我点击链接时,网址显示:

localhost:(port)/MyApplication/index.html#/about

我迷失了.

提前致谢!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值