Anurag Ranjan
Anurag Ranjan

Reputation: 169

facebook sharing in Angular Application

'Use Referral code xyzUvK to join the newest fantasy sports platform http://example.com . Earn extra points along with lots of exciting prizes. Don’t delay, join the match today! url',

code

html

 <a href="#" (click)="fb($event)"><img src="assets/imgs/fb.svg"/></a>

ts

fb(e) {
    let url = 'www.google.com';
    e.preventDefault();
    var facebookWindow = window.open(
      'https://www.facebook.com/sharer/sharer.php?u='+ 'Use Referral code ->' + this.userData.referCode + '   to join the newest fantasy sports platform' +  url + '. Earn extra points along with lots of exciting prizes. Don’t delay, join the match today! url',
      'facebook-popup',
      'height=350,width=600'
    );
    if (facebookWindow.focus) {
      facebookWindow.focus();
    }
    return false;
  }

Upvotes: 4

Views: 11028

Answers (2)

Sachin from Pune
Sachin from Pune

Reputation: 736

Please add meta tags in your index.html file

Markup Example

For example, here's how to mark up an article, news story or blog post with og:type="article" and several additional properties:

<meta property="og:url"                content="http://www.nytimes.com/2015/02/19/arts/international/when-great-minds-dont-think-alike.html" />
<meta property="og:type"               content="article" />
<meta property="og:title"              content="When Great Minds Don’t Think Alike" />
<meta property="og:description"        content="How much does culture influence creative thinking?" />
<meta property="og:image"              content="http://static01.nyt.com/images/2015/02/19/arts/international/19iht-btnumbers19A/19iht-btnumbers19A-facebookJumbo-v2.jpg" />

Upvotes: 1

dotconnor
dotconnor

Reputation: 1786

Facebook only allows you to share URLs, not prefilled text like twitter. So your u parameter has to be a URL.

https://developers.facebook.com/policy#control

Upvotes: 0

Related Questions