Angular 网站的Twitter共享按钮

Angular 网站的Twitter共享按钮,angular,twitter,share,Angular,Twitter,Share,我正在尝试使用以下代码在我的网站中实现一个twitter共享按钮 <a class="btn btn-small" href=" https://twitter.com/intent/tweet?source=tweetbutton&text={{name}}&url=https://stage.mutterfly.in+{{url}}" > <i class="fa fa-twitter" aria-hidden="true" style="hei

我正在尝试使用以下代码在我的网站中实现一个twitter共享按钮

<a class="btn btn-small" href=" https://twitter.com/intent/tweet?source=tweetbutton&text={{name}}&url=https://stage.mutterfly.in+{{url}}" >
      <i class="fa fa-twitter" aria-hidden="true" style="height: 30px; width:30px; color:black"></i>
</a>

其中,
{{text}}
来自api响应,{{url}}来自作为当前url的_route.url。 问题是此链接不接受我的动态数据,并且显示不安全的url错误


如何将动态文本和url插入此链接并使其工作?

您可以使用此代码,我使用codeigniter

<?php $url_share ="http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; ?>

<a style="background-color:#16A7F0;padding:5px;color:#FFF;" class="fa fa-twitter" href="https://twitter.com/intent/tweet?text=<?php echo $product['product_name'];?>&url=<?php echo $url_share;?>&via='$youtTags'" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=no,scrollbars=no,height=500,width=600');return false;" > Twitter</a>

您可以使用此代码,我使用codeigniter

<?php $url_share ="http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; ?>

<a style="background-color:#16A7F0;padding:5px;color:#FFF;" class="fa fa-twitter" href="https://twitter.com/intent/tweet?text=<?php echo $product['product_name'];?>&url=<?php echo $url_share;?>&via='$youtTags'" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=no,scrollbars=no,height=500,width=600');return false;" > Twitter</a>

您可以使用以下类型脚本中的方法获取值

<a class="btn btn-small" 
   [href]="getURL()" >
          <i class="fa fa-twitter" aria-hidden="true" style="height: 30px; width:30px; color:black"></i>
</a>

您可以使用typescript中的方法获取值,如下所示

<a class="btn btn-small" 
   [href]="getURL()" >
          <i class="fa fa-twitter" aria-hidden="true" style="height: 30px; width:30px; color:black"></i>
</a>

我正在使用Angular2。你能提供一些特定于Angular2的东西吗?你可以将这段代码更改为从查询行数组转换成Angular2-我在上面没有看到PHP标记。我使用的是Angular2。你能提供一些特定于Angular2的东西吗?你可以将这段代码更改为从查询行数组转换为Angular2-我在上面没有看到PHP标记。为什么不只是一个变量?而且,我没有看到任何类型脚本。为什么不只是一个变量呢?而且,我没有看到任何打字稿。