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
  • 9,534
  • 11
  • 45
  • 76
john smith
  • 723
  • 3
  • 8
  • 15

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
  • 48,275
  • 5
  • 65
  • 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,127
  • 13
  • 14