Skip to content

exportAs for nsRouterLinkActive Instance #928

Closed

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.

Activity

  1. sis0k0 commented on Aug 4, 2017

    @sis0k0
    Contributor

    @sean-perkins
    exportAs was added to routerLinkActive some months after it was initially introduced. We simply haven't updated the NS version of the directive. As you pointed out, the fix should be relatively simple. If you have the time to make a PR, we'll be happy to merge it. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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