16

I have a similar question to this post.

But adding "javascript" what was proposed in the answer didn't resolve my problem:

$compileProvider.urlSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|javascript):/);

My code looks something like:

<a ng-href="{{var1 ? '/home' : 'javascript: void(0);'}}" ng-bind="var2"></a>

But in the url, it produces an unsafe:javascript: void(0);

Paul
  • 10,381
  • 13
  • 48
  • 86
john smith
  • 733
  • 3
  • 8
  • 18

2 Answers2

41

I assume you use the latest version of AngularJS. The method name has been changed since that SO answer.

myapp.config(function($compileProvider){
  $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|javascript):/);
});

Demo link.

Buu
  • 49,745
  • 5
  • 67
  • 85
3

There must be some error in your code then. You can see it working just fine in this plunker:

http://plnkr.co/edit/fEujaU

Juliane Holzt
  • 2,135
  • 15
  • 14