我有这个 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/