I am building an app with angular4 and bootstrap 3.3.7 classes. I have a list:
<ul class="nav nav-sidebar">
<li><a [routerLink]="['/home']" [ngClass]="{'active': isActive(['home'])}">Overview </a></li>
<li><a [routerLink]="['/businessList']" [ngClass]="{'active': isActive(['businessList'])}">Businesses</a></li>
<li><a [routerLink]="['/storeList']" [ngClass]="{'active': isActive(['storeList'])}">Stores</a></li>
</ul>
When I click in any o the items the class is assign correctly and I can see which one was selected(seeing that it is highlighted), but when I use the browser back button, the isActive function is called and I see it it works as expected(returns true when the URL matches the route being evaluated) but the class is not applied, so I can not see what item is selected even if I am seeing the right router-outlet.
I have algo tried using this approach:
<li><a [routerLink]="['/storeList']" [class.active]="isActive(['storeList'])">Stores</a></li>
but the result is the same, the method is called and retunrs the expected value but the item is not highlighted.
This is my package.json:
{
"name": "WebApp",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng server --proxy proxy.conf.json",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.4.0-RC.0",
"@angular/common": "^4.4.0-RC.0",
"@angular/compiler": "^4.4.0-RC.0",
"@angular/compiler-cli": "^4.4.0-RC.0",
"@angular/core": "^4.4.0-RC.0",
"@angular/forms": "^4.4.0-RC.0",
"@angular/http": "^4.4.0-RC.0",
"@angular/platform-browser": "^4.4.0-RC.0",
"@angular/platform-browser-dynamic": "^4.4.0-RC.0",
"@angular/platform-server": "^4.4.0-RC.0",
"@angular/router": "^4.4.0-RC.0",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"ng2-file-input": "^0.1.13",
"ng2-file-upload": "^1.2.1",
"ngx-bootstrap": "^1.9.3",
"rxjs": "^5.4.3",
"ts-helpers": "^1.1.1",
"typescript": "^2.5.2",
"zone.js": "^0.8.17"
},
"devDependencies": {
"@angular/compiler-cli": "^4.3.6",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
"angular-cli": "1.0.0-beta.28.3",
"codelyzer": "~2.0.0-beta.1",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "~4.0.13",
"ts-node": "1.2.1",
"tslint": "^4.3.0",
"typescript": "~2.0.3"
}
}
What am I missing? let me know if any other info would be helpful.