繁体   English   中英

使图标在锚标记中可点击

[英]Making an icon clickable inside an anchor tag

我通过使用定位标记使整个li元素可点击:

 <li *ngIf="notification.payload.table">
      <a class="d-flex justify-content-between" (click)="updateTableNotificationReadStatus(notification)">
        <div class="d-flex flex-column">
          <span style="font-size: 1.1rem">
            <strong>{{notification.payload.username}}</strong> requested access for table - {{notification.payload.table}}.
              <span style="font-size: 0.9rem">{{notification.payload.time}}</span>
          </span>
          <span *ngIf="notification.payload.note"class="note">
            <span class="noteLabel">Note</span>
            <span> This is a note attached to it</span>
          </span>
        </div>
        <span>
          <fa-icon [icon]="faClose" class="ml-auto" (click)="deleteNotification(notification)"></fa-icon>
        </span>
      </a>
    </li>

当我单击该图标时,该通知将被删除,但由于我不希望使用的功能,我也将重定向到另一个页面。

在同一元素上时,如何使关闭图标可单击而不被重定向?

在我看来,您需要与此问题类似的东西AngularJS ng-click stopPropagation

停止宣传活动

$event.stopPropagation();

我实现了使用:

 deleteNotification(e, notification) {
    e.stopPropagation();
  }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM