angular ngx-bootstrap onClick on alert module

问题描述 投票:0回答:1

我正在使用ngx-bootstap警报模块来显示警报。当有人点击提醒中的帐号时,我想显示模式以及帐户的更多详细信息。我没有在alert模块上找到onClick事件。有关闭事件的事件处理程序,但点击事件没有任何内容。

我试图使用innerHTML来包含代码来创建onClick之类的功能,但它不起作用。

这是html部分 -

<div *ngFor="let alert of alerts">
          <alert [type]="alert.type" [dismissible]="dismissible">
              <span [innerHTML]="alert.msg | safe: 'html'"></span>
            </alert>
</div>

我已经定义了安全管道工作正常。

这是警报的返回值 -

[{
            "type": "success",
            "msg": "Adjustments - Marry Jonson <a href='javascript:folioClicked(1305879);'>#130-5879</a> Amount $102."
        }]

我在组件中定义了folioClicked()函数。但是,我不知道怎么称呼它。我尝试使用javascript调用:folioClicked但是这不起作用并且给出错误“Uncaught ReferenceError:folioClicked未定义为:1:1”。

它似乎试图在javascript中找到代码。我能理解其中的原因。但是,无法通过innerHTML代码找到调用组件函数的方法。

angular typescript ngx-bootstrap
1个回答
0
投票

您可以尝试以这种方式在警报中添加单击事件。我希望它会对你有所帮助。

<alert type="success">
 <strong>Well done!</strong> You successfully read this important alert message.
  <a (click)="fooClick(accNo)">Account.no. {{accNo}}</a>
</alert>

Here I am adding running snippet link to help you it.

© www.soinside.com 2019 - 2024. All rights reserved.