javascript - Ionic/Angular JS - 如何在 onclick 中解析 {{value}}

标签 javascript angularjs ionic-framework

我有这个 Angular JS HTML:

<ion-view view-title="Articol">
  <ion-content class="padding">
    <img ng-src="{{article.image}}">
    <h2>{{article.title}}</h2>
    <p>{{article.published}}</p>
    <p ng-bind-html="article.text"></p>
    <p>
      <button onclick="window.plugins.socialsharing.shareViaFacebook(null /* msg */, null /* img */, '{{article.url}}')">Facebook</button>
      <button onclick="window.plugins.socialsharing.shareViaTwitter(null /* msg */, null /* img */, '{{article.url}}')">Twitter</button>
    </p>
  </ion-content>
</ion-view>

一切正常,但不是 {{article.url}}里面onclick="" .如果我把 {{article.url}}<p></p> 里面它工作正常。 我该如何解决这个问题?

最佳答案

更好的方法可能是保持它完全干净(即 html 中没有脚本),它可以实现为

<button ng-click="posttofb()">Facebook</button>

在 Controller 中

app.controller(funcion($scope){    

   $scope.posttofb = function (){    
      window.plugins.socialsharing.shareViaFacebook(null, null, $scope.article.url);
   }

});

关于javascript - Ionic/Angular JS - 如何在 onclick 中解析 {{value}},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40343544/

相关文章:

javascript - 为什么这些正则表达式什么也没找到? JavaScript

javascript - JS中打印json数组

javascript - 函数表达式可以转换为 lambda 表达式

javascript - AngularJS - 检索评估的属性

AngularJS InfDig 错误(无限循环),ng-repeat 函数返回对象数组

javascript - 将 ng-click 处理程序添加到 angularjs 中的重复元素

javascript - 如何使用 Angular 的 $q promise 检索 HTTP 状态代码?

reactjs - Ionic/React/TypeScript,使用react-router history.push, history.replace and history.goBack动画触发两次

ionic-framework - 在 ionic cordova android 中构建时出现问题

javascript - Ionic - 如何在 Ionic 复选框中获取所选项目