Search code examples
angularjsangularjs-directiveanchorhrefwhatsapp

Whatsapp Sharing in AngularJS


Simple as it should be, it won't work as this code can't detect AngularJS codes.

    <a href="whatsapp://send?text={{challenge.challenge_title}}" 
            data-action="{{FullURL}}">Whatsapp</a>

Do i need a directive for this? If yes, what is it? Someone with experience in AngularJS, kindly help.


Solution

  • You need to sanitize anchor href inside your config phase of angular, that will allow your href with whatsapp prefix.

    Code

    app.config(function($compileProvider){
       //other configuration code here
       $compileProvider.aHrefSanitizationWhitelist(/^\s*(whatsapp):/);
    })
    

    Look this SO Question for details.