AngularJS转换我的ng-href url“斜线”进入“%2f” [英] AngularJS converting my ng-href url "slash" into "%2f"
问题描述
我有一个angularJS应用程序,它是一个库。对于每张图片,与之相关的是 ng-href
,其中包含#/ {{files.id}}
。
I have an angularJS application that is a gallery. For each picture, associated with it is an ng-href
with #/{{files.id}}
.
< a ng-href =#/ {{files.id}}...
然而,当我点击它时,最终显示的URL是
However, when I click it, the URL that is ultimately displayed is
http :// localhost:3000 / gallery#%2F0
它会破坏我的角度路由
when('/ gallery /:imageID',{
templateUrl:'load_image.html'
})。
有人可以向我解释如何正确编码网址吗?或者只使用不编码正斜杠的东西?
Can someone explain to me how to encode the URL's correctly? Or just use something that doesn't encode the forward slash?
推荐答案
由于 aa077e8 ,用于$ location hash-bang网址的默认哈希前缀已从空字符串('')更改为bang('!')。
Due to aa077e8, the default hash-prefix used for $location hash-bang URLs has changed from the empty string ('') to the bang ('!').
你应该试试这个。
index.html
<li class="active"><a href="#/">Home</a></li>
<li><a href="#/about">About</a></li>
app.js
angular.module('appRoutes',['ngRoute'])
.config(function($routeProvider, $locationProvider){
$locationProvider.hashPrefix('');
$routeProvider
.when('/',{
templateUrl:'app/views/pages/home.html'
})
.when('/about',{
templateUrl:'app/views/pages/about.html'
});
});
这篇关于AngularJS转换我的ng-href url“斜线”进入“%2f”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!