kriskbx/whatsapp-sharing

Working with AJAX and Dynamic URL with AngularJS Directive

Closed this issue · 1 comments

Hi Kris,

I am using it in a directive in my angular app. I am able to make a call to WASHAREBTN.crBtn(scope); and get the button. The issue that I am facing is to set the url dynamically. I set the url by using this code:

element.find('a.wa_btn').data('href', scope.url);

but is not getting set. I am still getting the window.url only. Any ideas, where I am making mistakes.
I tried setting it up in my directive html as well like:

<a href="whatsapp://send" data-text="Take a look at this awesome content:" data-href="{{url}}" class="wa_btn wa_btn_s" style="display:none">Share</a>

But, then it showed up the link in the whatsapp message as {{url}} only. I check in my debugger the value for {{url}} is getting set correctly.

Truly appreciate your help.

Thanks,
Manik Mittal

To add the dynamic url, i used the following code:

element.find('.wa_btn').attr('data-href', scope.url);

in the directive js in place of:

element.find('a.wa_btn').data('href', scope.url);