Angular onclick内的字符串插值(离子2和角2)

Angular onclick内的字符串插值(离子2和角2),angular,typescript,ionic2,syntax-error,ionic3,Angular,Typescript,Ionic2,Syntax Error,Ionic3,简单的问题是,我试图在我的Ionic 2应用程序的“onclick”中传递一个字符串,但它总是给我一个错误 <button onclick="window.plugins.socialsharing.shareViaWhatsApp(null, null, '{{sound.file}}', null)">Enviar no whats</button> 应该是这样的: <button (click)="share(sound.file)">Enviar n

简单的问题是,我试图在我的Ionic 2应用程序的“onclick”中传递一个字符串,但它总是给我一个错误

<button onclick="window.plugins.socialsharing.shareViaWhatsApp(null, null, '{{sound.file}}', null)">Enviar no whats</button>

应该是这样的:

<button (click)="share(sound.file)">Enviar no whats</button>

您应该避免在视图中包含逻辑,而是将其放在组件代码中。

尝试
(单击)=>。“
很高兴听到这个消息:)
<button (click)="share(sound.file)">Enviar no whats</button>
public share(file: string): void {
    window.plugins.socialsharing.shareViaWhatsApp(null, null, file, null);
}