Skip to content

exportAs for nsRouterLinkActive Instance #928

@sean-perkins

Description

@sean-perkins

Looking over the routerLinkActive specification vs. the nsRouterLinkActive specification, I noticed you aren't leveraging the exportAs functionality.

Is there a specific reason behind that?

nsRouterLinkActive
routerLinkActive

It would be beneficial to have access to the nsRouterLinkActive directive reference, so that we can access helper functions like isActive.

The use case I am currently stuck in, is trying to eliminate UIView containers in NativeScript. My navigation bar is a custom element that iterates and creates icon buttons. Due to how the views are constructed, we have to place the nsRouterLinkActive on the parent container iterating, otherwise it's not registered.

Our application then has custom branding that injects CSS to overwrite the router links default styling.

Currently I have no "neat" way of accessing if the router link is active or not, besides writing a helper function to check the URL agains the router link I'm passing in.

Desired Code Example:

    <app-navbar-item *ngFor="let link of userLinks"
        [nsRouterLinkActive]="['active']"
        [nsRouterLink]="link.menuLink"
         #rla="nsRouterLinkActive"
        [active]="rla.isActive"
        [item]="link"></app-navbar-item>

This would most likely require a small refactor in the nsRouterLinkActive implementation, as I see you are assigning isActiveLinks in a local reference to a function's scope.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions