Skip to content

routerLinkActive.isActive not correct on pageLoad #24762

@david-bulte

Description

@david-bulte

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:

Current behavior

Consider the following markup in a navigation toolbar:

    <button mat-button class="nav-button"
            *ngFor="let item of navItems" [routerLink]="['/', item.name]"
            routerLinkActive="active-link"
            #rla="routerLinkActive" [disabled]="rla.isActive">
      {{item.name}} {{rla.isActive}}
    </button>

When the page loads, the "active-link" class is set for the "active route button". However, it's isActive property is false. After clicking a button, thereby changing the active route, the directive acts correctly.

Expected behavior

The routerLinkActive.isActive property should be true when the page loads.

Environment


Angular version: 6.0.8

Browser:
- [ x] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions