Why does ng-href behave strangely when parsing a geo string

I have several geo lines, such as geo:0,0q=1+a+bc , and I'm going to assign this an ng-ref anchor tag. Like below, I do it.

HTML

 <a ng-href="{{geoString}}">Location</a> </br> 

HTML is perfectly processed above the tag, but unsafe: added unsafe: string geo:0,0q=1+a+bc inside the href attribute

Highlighted HTML

 <a ng-href="geo:0,0q=12345+jefferson+st" href="unsafe:geo:0,0q=12345+jefferson+st">Location</a> 

Plunkr with a demonstration of the problem.

I don't want unsafe: inside href , any idea why it pre-adds unsafe: to geoString and how to remove it?

+2
source share
1 answer

You need to use aHrefSanitizationWhitelist ([regexp]);

regex must match the URL of your So. In your case, it should be like

  $compileProvider.aHrefSanitizationWhitelist(/^\s*(geo):/); 

regEx: - starting with geo followed by ':'

See the $ compileProvider Documentation for more information.

Plunker

+3
source

All Articles