angular2-router

Get current route without parameters

假如想象 提交于 2020-06-10 07:21:10
问题 I need to get my current route without params in Angular 2, I found a way to get the current route with params as follows: this.router.url and then split it: this.router.url.split(';')[0] But this looks as workaround, I think there should be better way? 回答1: parseTree from Router helps fetching the segments without any knowledge about url structure. import { Router } from '@angular/router'; ... constructor(private router: Router) {} ... const urlTree = this.router.parseUrl(url); const

Get current route without parameters

落花浮王杯 提交于 2020-06-10 07:20:46
问题 I need to get my current route without params in Angular 2, I found a way to get the current route with params as follows: this.router.url and then split it: this.router.url.split(';')[0] But this looks as workaround, I think there should be better way? 回答1: parseTree from Router helps fetching the segments without any knowledge about url structure. import { Router } from '@angular/router'; ... constructor(private router: Router) {} ... const urlTree = this.router.parseUrl(url); const

How to handle multiple queryParams in Angular2

◇◆丶佛笑我妖孽 提交于 2020-01-11 06:13:10
问题 I'm trying to implement a filtering mechanism in a new Angular2 app, that would allow me to filter a list of entries in an array. The entries may have around 20 properties that could be filtered on. I have so far created a list of filters in one component and then a list component that is routed to, as a child. I then planned to pass the filters as queryParams through the router. Starting with just one filter this was fine: On the send side I had: this.router.navigate(['/findlist'],

Angular 2 [routerLink] Not Resolving in Browser

孤街浪徒 提交于 2020-01-07 06:43:08
问题 Without adding too much code or documentation to my question, I'm having a resolving issue with the [routerLink] code for our Angular 2 Demo: Versioning Node.js - v4.4.7 @angular - 2.0.0-rc.1 app/app.component.ts @RouteConfig([ { path: '', name: 'TasksComponent', component: TasksComponent }, { path: 'tasks/editor', name: 'TaskEditorComponent', component: TaskEditorComponent }, { path: 'timer', name: 'TimerComponent', component: TimerComponent } ]) app/app.component.html <nav class="navbar

LoggedInOutlet angular2 authentication - Router v3.0.0-alpha8 - Where is ComponentInstruction?

房东的猫 提交于 2019-12-31 03:17:22
问题 I am using code like this to extend RouterOutlet and create app wide authentication and route protection import {Directive, Attribute, ViewContainerRef, DynamicComponentLoader} from '@angular/core'; import {Router, ComponentInstruction} from '@angular/router'; import {Router} from '@angular/router'; import {RouterOutletMap} from '@angular/router/src/router_outlet_map'; import {RouterOutlet} from '@angular/router/src/directives/router_outlet'; import {Authentication} from '../common

LoggedInOutlet angular2 authentication - Router v3.0.0-alpha8 - Where is ComponentInstruction?

你。 提交于 2019-12-31 03:17:09
问题 I am using code like this to extend RouterOutlet and create app wide authentication and route protection import {Directive, Attribute, ViewContainerRef, DynamicComponentLoader} from '@angular/core'; import {Router, ComponentInstruction} from '@angular/router'; import {Router} from '@angular/router'; import {RouterOutletMap} from '@angular/router/src/router_outlet_map'; import {RouterOutlet} from '@angular/router/src/directives/router_outlet'; import {Authentication} from '../common

How can I specify query parameters by routerLink directive

这一生的挚爱 提交于 2019-12-19 17:45:32
问题 I am experimenting the new router (version 3.0.0-alpha.7) and would like to know how to specify query parameters by routerLink directive? The Router.navigate() method below generates a URL like http://localhost:3000/component-a?x=1 this.router.navigate(['/component-a'], {queryParams: {x: 1}}); However, I can't figure out how to do the same thing with the routerLink directive. Template like below returns parser error... <a [routerLink]="['/component-a'], {queryParams: {x: 1}}">Component A</a>

Angular2 router, get route data from url, to display breadcrumbs

大兔子大兔子 提交于 2019-12-17 09:31:46
问题 I am using angular2 router. To draw the breadcrumb of an url, lets say site.com/a/b/c/15 I do the following: Get the route of site.com/a/b/c/15 and get the pretty name associated to the route Get the route of site.com/a/b/c and get the pretty name associated to the route Get the route of site.com/a/b and get the pretty name associated to the route Get the route of site.com/a and get the pretty name associated to the route So lets say I do have the following routes: { path: 'a', component: A,

Angular 2 routes current url with params

守給你的承諾、 提交于 2019-12-12 05:36:47
问题 I'm trying to use Angular 2 rc-4 with new Router. export const appRoutes: RouterConfig =[ { path: "", component: HomeComponent, terminal: true, data: { title: "Home" } }, { path: "Users", component: UserListComponent, data: { title: "Users" } }, { path: "Users/:id", component: UserEditComponent, data: { title: "Edit User" } } ]; Then I subscribe to change route event. When event fires I want to find item from appRoutes The problem is with url with params: Users/:id I don't know how to compare

Cannot match any routes: ''

╄→尐↘猪︶ㄣ 提交于 2019-12-12 03:47:27
问题 I have a defined route in angular2 application and receive such error: Cannot match any routes: '' export const routes: Routes = [{ path: '', component: MainComponent, children: [{ path: 'callCenter', component: CallCenterComponent, resolve: { countries: CountriesResolver }, }, { path: 'vehicle', component: VehicleComponent, resolve: { vehicleCategories: VehicleCategoryResolver, vehicleOptions: VehicleOptionResolver }, }, { path: 'territory', component: TerritoryComponent, resolve: {