Skip to content

exportAs for nsRouterLinkActive Instance #928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sean-perkins opened this issue Aug 3, 2017 · 1 comment
Closed

exportAs for nsRouterLinkActive Instance #928

sean-perkins opened this issue Aug 3, 2017 · 1 comment

Comments

@sean-perkins
Copy link
Contributor

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.

@sis0k0
Copy link
Contributor

sis0k0 commented Aug 4, 2017

@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. :)

sis0k0 pushed a commit that referenced this issue Aug 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants