为什么NG-的href怪异的行为在解析字符串缘 [英] Why ng-href behaving weird while parsing geo string
问题描述
我有多个地理串像地理:0,0q = 1 + A + BC
,我要去分配这NG-REF锚标记。像下面我做的。
I've multiple geo string like geo:0,0q=1+a+bc
, and I'm gonna assign this to ng-ref of the anchor tag. Like below I'm doing it.
HTML
<a ng-href="{{geoString}}">Location</a> </br>
以上标签渲染罚款HTML,但加入不安全:
字符串地理:0,0q = 1 + A + BC
在的href
属性
渲染HTML
<a ng-href="geo:0,0q=12345+jefferson+st" href="unsafe:geo:0,0q=12345+jefferson+st">Location</a>
Plunkr 与展示的问题。
Plunkr with demonstrating issue.
我不希望不安全:
在的href
,任何想法,为什么它是pre-追加不安全:
在地理字符串
&安培;我如何去除呢?
I don't want unsafe:
inside href
, Any idea why it is pre-appending unsafe:
before geoString
& How do i remove it?
推荐答案
您需要使用aHrefSanitizationWhitelist([正则表达式]);
You need to use aHrefSanitizationWhitelist([regexp]);
正则表达式应该符合您的的网址所以你的情况应该是这样
regex should match the url of your's So in your case it should be like
$compileProvider.aHrefSanitizationWhitelist(/^\s*(geo):/);
正则表达式: - 从地缘后跟:
regEx:- starting with geo followed by ' : '
请参见 $ compileProvider文档获取更多信息。
这篇关于为什么NG-的href怪异的行为在解析字符串缘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!