Best way to handle external and internal links angular

Discussão em 'Angular' iniciado por Jake, Dezembro 23, 2024.

  1. Jake

    Jake Guest

    the problem is these links are all dynamic and come from a cms so they could be internal or external,

    i have a flag coming from the backend so i know whether it is external or not but i don't really want to add a ngIf and have 2 duplicate elements. i tried adding href and routerLink together but angular doesn't like that so i was thinking of making a custom directive.

    <a
    [href]="component?.external ? component?.localizedUrlLink : null "
    [routerLink]="!component?.external ? component?.localizedUrlLink : null "
    [title]="component?.media?.altText"
    class="article-link"
    >


    Has anyone faced similar problems and how they overcome this?

    Continue reading...

Compartilhe esta Página