2016-10-31 10 views
1

onclickの内{{値を}}解析するにはどうすればこの角度JS HTMLを持っている:イオン/アンギュラJS -

<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> 

すべてがonclick=""内部{{article.url}}正常に動作していないが。私が<p></p>の中に{{article.url}}を置くとうまくいきます。 どうすればこの問題を解決できますか?

+0

なぜ "ng-click"を使用しないのですか? – katmanco

+0

上記のコードに基づいて私に例を挙げてもらえますか? – Andrei

答えて

2
から単一引用符を削除します
app.controller(funcion($scope){  

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

}); 
0

より良いアプローチは、完全にクリーンな(つまり、HTMLにはスクリプトが)、それはコントローラ

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

ようにして達成することはできませんそれを維持することができ{{article.url}}

<button onclick="window.plugins.socialsharing.shareViaFacebook(null /* msg */, null /* img */, {{article.url}})">Facebook</button> 
+0

同じこと。それはURLで置き換えられません。 Andrei

+0

URLがハードコードされていると機能しますか内部? – whyyie

+0

はい、内部でURLをハーコードすると完全に動作します。 – Andrei