using ng-href with javascript in anchor tag (bookmarklet)

552 Views Asked by At

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

1

There are 1 best solutions below

0
sam On

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‌​):/);
}]);