1

I am trying to create a bookmarklet on an anchor tag using angularjs.

When the script is static, there is no need to use angularjs code. but when it is dynamic, both href and ng-href are appending 'unsafe' to the JavaScript.

tried DOM manipulation and it worked perfectly.

Instead of scriptlet, if i am using a URL, both href and ng-href are working properly

http://plnkr.co/edit/0l4AbOLbCPhE5c9OLWD2?p=preview

CodingNinja
  • 801
  • 9
  • 17
  • 1
    This might give you a clue about your issue.. http://stackoverflow.com/questions/15637133/unsafe-link-in-angular – Karthik Jan 15 '15 at 18:44
  • Thanks @karthik. It worked after using `$compileProvider.aHrefSanitizationWhitelist(/^\s*(javascript):/);` – CodingNinja Jan 15 '15 at 19:03

1 Answers1

0

I tried href and the below code, but it did have the unsafe:javascript in front of the JavaScript function.

angular.module("app").config(['$compileProvider', function ($compileProvider) {
    $compileProvider.aHrefSanitizationWhitelist(/^\s*(javascript‌​):/);
}]);
mmvsbg
  • 3,570
  • 17
  • 52
  • 73
sam
  • 85
  • 1
  • 8