gpt4 book ai didi

javascript - Angular RouterLink 在新选项卡中运行

转载 作者:行者123 更新时间:2023-12-02 22:07:46 24 4
gpt4 key购买 nike

我正在尝试申请特定的 RouterLink。

问题:我有一个从数据库创建的动态菜单。

        <div class="sidebar-toggler">
<span></span>
</div>
</li>
<li class="heading">
<h3 class="uppercase">Menú</h3>
</li>
<!-- List of Main Category Elements -->
<li class="nav-item" *ngFor="let layout of layouts" appIsOpen (arrowUp)="callSomething($event)">
<a class="nav-link">
<i class="{{layout.icontag}}"></i>
<span class="title">{{layout.categoryName}}</span>
<span class="arrow" *ngIf="layout.items.length > 0" [ngClass]="{ 'open': arrowUp }"></span>
</a>
<!-- List of SubMenus -->
<ul class="sub-menu" *ngFor="let subitem of layout.items">
<li class="nav-item">
<a routerLink="{{subitem.state}}" target="_blank" class="nav-link" rel="noopener no referrer">
<span class="title">{{subitem.moduleName}}</span>
</a>
</li>
</ul>
</li>
</ul>```

Here's the piece of code im touching: <a routerLink="{{subitem.state}}" target="_blank" class="nav-link" rel="noopener no referrer">

最佳答案

我想只有一种方法:

<a href="yourdomain.com/{{subitem.state}}" target="_blank" class="nav-link" rel="noopener no referrer">

对目标使用插值:

[target] ="condition ? '_blank' : 'something' 

关于javascript - Angular RouterLink 在新选项卡中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59666631/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com