Skip to content
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

Empty links by ng2 uiSref directive #26

Closed
christopherthielen opened this issue Jan 21, 2017 · 4 comments
Closed

Empty links by ng2 uiSref directive #26

christopherthielen opened this issue Jan 21, 2017 · 4 comments
Labels
Milestone

Comments

@christopherthielen
Copy link
Member

From @artaommahe on January 8, 2017 20:16

uiSref directives binds 'null' string to href on provided null or empty string '' state.

current behavior

<!-- template -->
<a [uiSref]="null">smth</a>
<a [uiSref]="''">smth</a>

<!-- result -->
<a href="null">smth</a>

expected no href attribute (null property value?)

<!-- result -->
<a>smth</a>

It's required for dynamic links when for some cases href should be empty and link clicks does not trigger any state changes (access rights check e.x.)

Copied from original issue: angular-ui/ui-router#3248

@christopherthielen
Copy link
Member Author

From @artaommahe on January 9, 2017 20:16

Fixed expected result html, due to empty href forced to reload page

@gcca
Copy link
Contributor

gcca commented Mar 30, 2017

I created a PR. But the bug cannot be shown on unit test with PhantomJS (unlike Firefox or Chrome launcher).

@rochapablo
Copy link

None of this is working:

<li *ngFor="let item of items">
   <a [uiSref]="item.link">{{ item.title }}</a>
   <a uiSref="item.link">{{ item.title }}</a>
   <a uiSref=".link">{{ item.title }}</a>
</li>

What could I be doing wrong?

@rochapablo
Copy link

Never mind, the problem was my items links which was

[
   { link: '/stores', title: 'Stores' }
]

Just removed the / and all worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants