I am struggling to get this to work.
<li [class.active]="router.isRouteActive(router.generate(['/SomeRoute']))">
To bug test this I want to console.log the current route to see what the actual route is, but am not sure how to go about doing this in Angular2?
EDIT:
{
"name": "angular2-boilerplate",
"version": "1.0.0",
"scripts": {
"lite": "lite-server",
"gulp": "gulp",
"start": "concurrent \"npm run gulp\" \"npm run lite\" "
},
"license": "ISC",
"dependencies": {
"angular2": "2.0.0-beta.14",
"es6-shim": "^0.35.0",
"ng2-pagination": "0.0.1",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"systemjs": "0.19.25",
"zone.js": "0.6.6"
},
"devDependencies": {
"autoprefixer": "^6.3.5",
"cssnano": "^3.4.0",
"concurrently": "^2.0.0",
"gulp": "^3.9.0",
"gulp-ext-replace": "^0.2.0",
"gulp-imagemin": "^2.4.0",
"gulp-postcss": "^6.0.1",
"gulp-sourcemaps": "^1.6.0",
"gulp-typescript": "^2.10.0",
"gulp-uglify": "^1.5.1",
"lite-server": "^2.1.0",
"postcss": "^5.0.13",
"postcss-scss": "^0.1.3",
"precss": "^1.3.0"
}
}
what you are looking for is the location service
console.log(location.path())
You can use RouteRegistry to find out information about other routes inside other component's code:
recognize(url: string, ancestorInstructions: Instruction[]) : Promise<Instruction>
Given a URL and a parent component, return the most specific instruction for navigating the application into the state specified by the url
Official docs: https://angular.io/docs/ts/latest/api/router/RouteRegistry-class.html
Googd article on Angular2 router details: http://julienrenaux.fr/2015/12/25/angular2-series-routing/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.