Nicoleta Wilskon
Nicoleta Wilskon

Reputation: 697

Sharing a link in facebook

I am sharing a link http://35.154.102.35/index.html#/shareProfilein facebook. But sharing doesnt happen , it take shareProfile as userid and redirect to profile of person share.profile.What can be done to redirect to my link ?

HtmL:

 <div class="share-links">
      <a href="http://facebook.com/sharer.php?u={{shareVDetails}}" class="fa fa-facebook" target="_blank"></a>
    </div>

JS:

$scope.shareVDetails = "http://35.154.102.35/index.html#/shareProfile";

Upvotes: 1

Views: 173

Answers (3)

try this

$scope.shareVDetails = "http://35.154.102.35/index.html#/shareProfile";

$scope.facebook = "http://facebook.com/sharer.php?u=" + $scope.shareVDetails;

on html

<a href="{{ facebook }}" >

Upvotes: 1

Bartek Cichocki
Bartek Cichocki

Reputation: 661

You need to encode url, because the hash sign is treated like it is part of facebook link not yours. So:

$scope.shareVDetails = encodeURIComponent("http://35.154.102.35/index.html#/shareProfile");

Upvotes: 0

user441521
user441521

Reputation: 6988

Generally you want to use ng-href for links if you're using data in a controller as part of the link as per their doc.

https://docs.angularjs.org/api/ng/directive/ngHref

Upvotes: 0

Related Questions