Issue
I am working on a task where I am looping an array inside a tag & using target="_blank" attribute but one of the array element should not want this target="_blank" attribute so what to do?
<ul *ngIf="item.menu">
<li *ngFor="let subMenu of item.menu">
<a href="{{subMenu.link}}" target="_blank">{{'landing.menu.' + subMenu.name | translate}}</a>
</li>
</ul>
Solution
You can use [target] around any tag property to add JS/TS code to it.
<a href="{{subMenu.link}}" [target]="condition ? '_blank' :'other target type'">{{'landing.menu.' + subMenu.name | translate}}</a>
Other target type list: https://www.w3schools.com/tags/att_a_target.asp
Answered By - Keryanie
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.