The problem of angular5 realizing hover effect through self-defined instructions

I implemented a simple navigation bar hover effect through instructions, and the effect is as follows:

you can see that the mouseLeave event is triggered when the pointer is on the dash line, asking how to stop it.

nav-hover.directive.ts :

@Directive({
  selector: "[appNavHover]"
})
export class NavHoverDirective {
  constructor(private el: ElementRef) { }

  @Input("appNavHover") index: number;

  @Input() active: HTMLElement;

  @HostListener("mouseenter", ["$event"]) onMouseEnter(e) {
    this.setActiveLine();
  }

  @HostListener("mouseleave", ["$event"]) onMouseLeave(e) {
    const index = this.getActived();

    this.setActiveLine(index);
  }

// 
private setActiveLine(index = this.index) {...}

// active
private getActived(): number {...}

}

app.component.html

...
<nav class="col-5 col-offset-1 header-item clearfix" -sharpnavWrap>
  <a class="block pull-left"
     *ngFor="let nav of navData; let i = index; let last = last;"
     [routerLink]="nav.link"
     routerLinkActive="active"
     [routerLinkActiveOptions]="{ exact: nav.link === "/" ? true : false }"
     [appNavHover]="i"
     [active]="activeLine">
    {{ nav.name }} {{ last ? forRendered(activeLine, navWrap) : "" }}
  </a>
  <i class="center-block active-line animated" -sharpactiveLine></i>
</nav>
...
Mar.07,2021

is it possible to put lines and text in the same container instead of adding them on the outside? For example, navigate the border-bottom of item

Menu