ionic2:使用[innerHTML]和绑定点击事件显示html标签

时间:2017-05-19 09:08:37

标签: onclick ionic2 innerhtml

在html中,代码如下:

<div class="detail-style">
    <div [innerHTML]="html" *ngIf="html"></div>
  </div>

html是一些像这样的html标签:

<div><span>test</span></div>
<attach onclick="downloadAttach('attachName', 'attachPath')">click this to download attach</attach>

它可以正常显示,当我单击attach时,它会抛出downloadAttach is not defined异常,但我在ts文件中定义了downloadAttach方法。 我不知道如何解决这个问题。我花了一天时间。 非常感谢你帮助我。

1 个答案:

答案 0 :(得分:0)

创建

<script>function downloadAttach(){...}</script>
index.html中的