如何生成URL带AngularJS codeD锚链接? [英] How to generate url encoded anchor links with AngularJS?
本文介绍了如何生成URL带AngularJS codeD锚链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<a href="#/search?query={{address}}" ng-repeat="address in addresses">
{{address}}
</a>
生成的而非URL连接codeD,如果我理解正确的链接。什么是正确的方式连接code #/搜索?查询= {{}地址}
?
例如地址是 1260第六大道,纽约
。
推荐答案
您可以在JavaScript中使用本地连接codeURIComponent
。
此外,你可以把它转换成字符串过滤器,以利用它。
You can use the native encodeURIComponent
in javascript.
Also, you can make it into a string filter to utilize it.
下面是制作的例子逃跑
过滤器。
Here is the example of making escape
filter.
JS:
var app = angular.module('app', []);
app.filter('escape', function() {
return window.encodeURIComponent;
});
HTML
<a ng-href="#/search?query={{address | escape}}">
(更新:适应它采用Karlies的回答 NG-HREF
而不是简单的的href
)
这篇关于如何生成URL带AngularJS codeD锚链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文