[英]how to pass url using angular js in facebook sharing button
這是html共享按鈕,點擊時共享data-href中給出的url。
問題:我想根據條件使用角度js傳遞URL。 我已經在$ scope.sd中存儲了url如何在data-href中使用它。
我試過把data-href =“sd”但是它沒有用。
<div id="fb" class="fb-share-button" data-href="http://sample-env.yqk6qkszsb.us-west-2.elasticbeanstalk.com/static/polls/img/icon.png" data-layout="button_count" data-size="large" data-mobile-iframe="true"><a class="fb-xfbml-parse-ignore" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&src=sdkpreparse">Share</a></div>
app.js
var app = angular.module('myApp',[]);
app.controller('ctrl',function($scope){
$scope.wish=["Birthday","Makar Shankranti","Valentine Day","Holi","Friendship Day"];
$scope.show=true;
$scope.isVisible=false;
$scope.sd='http://nishantsingh.tk'; // I want to pass this url
$scope.create = function(name,choice){
$scope.user=name;
if(!$scope.user){return $scope.errmsg="Please enter your name";}
if(!$scope.choice){return $scope.errmsg="Please choose your wish";}
$scope.show=false;
$scope.isVisible = true;
$scope.day=choice;
if(choice=='Birthday'){$scope.bg={background : 'url(../../static/polls/img/birthday.gif)'}}
else if (choice=='Makar Shankranti'){$scope.bg={background : 'url(../../static/polls/img/makar.gif)'}}
else if (choice=='Valentine Day'){$scope.bg={background : 'url(../../static/polls/img/valentine.gif)'}}
else if (choice=='Friendship Day'){$scope.bg={background : 'url(../../static/polls/img/friendship.gif)'}}
else if (choice=='Holi'){$scope.bg={background : 'url(../../static/polls/img/holi.gif)'}}
};
$scope.anCreate=function(anotherName,choice){
if(!$scope.anotherName){return $scope.msg="Please enter your name";}
$scope.user=anotherName;
};
});
您可以嘗試使用data-href="{{sd}}"
<div id="fb" class="fb-share-button" data-href="{{sd}}" data-layout="button_count" data-size="large" data-mobile-iframe="true"><a class="fb-xfbml-parse-ignore" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&src=sdkpreparse">Share</a></div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.