javascript - 使图标在 anchor 标记内可点击

标签 javascript html css font-awesome

我通过使用 anchor 标记使整个 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>

当我点击 fa-icon 时,通知被删除,但由于我不想要的功能,我也被重定向到另一个页面?

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

最佳答案

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

停止传播事件

$event.stopPropagation();

关于javascript - 使图标在 anchor 标记内可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52498607/

相关文章:

javascript - 发送 'this' 作为参数 |是否可以?

javascript - ng-repeat,数据更新后不更新表吗?

html - 悬停时更改多个 css 元素

html - 如何让图片固定在右下角

JavaScript - 在特定条件下更新 &lt;textarea&gt; 值并将其附加到 <div>

javascript - 传单未对图层进行样式设置

javascript - 只有一个列表元素在页面加载时排在第一位

javascript - 可以使用 React 中的属性将哪些不同类型的 Prop 从一个组件发送到另一个组件?

javascript - 无法更改 JavaScript 中的文本字段

html - MVC3网站如何应用StyleSheet?