angular2-routing

Angular2 : get parent router data

做~自己de王妃 提交于 2019-12-18 08:40:04
问题 I'm creating a component under route /blabla/:id/blabla/:secondid First part of my url "/blabla/:id/..." is managed by my first routing component. Then, a second router manages the second part of url. In my component, I can easy access to my ":secondid" in RouteData. But I wonder how I can access my ":id" from there. Any idea ? 回答1: Pass the first id along with data-binding. 回答2: You must use Injector to get parents data. This is a sample code extrated from here using the feature. this.params

Error: (SystemJS) Can't resolve all parameters for ActivatedRoute: (?, ?, ?, ?, ?, ?, ?, ?)

不羁岁月 提交于 2019-12-18 07:32:11
问题 I'm trying to inject ActivatedRoute component into my component to access the ID of the object I'm editing (or to find out, there's no ID param, new object is created). I've created only the template for the component, and when I load start page (not event the page with the component I want to use) I get the following error: Error: (SystemJS) Can't resolve all parameters for ActivatedRoute: (?, ?, ?, ?, ?, ?, ?, ?). This is my code: import { Component, OnInit } from '@angular/core'; import {

No provider for ActivatedRoute - Angular 2 RC5

為{幸葍}努か 提交于 2019-12-18 07:30:24
问题 After upgrading to Angular 2 RC5 (from RC4) it seems I can no longer inject ActivatedRoute into my components. ORIGINAL EXCEPTION: No provider for ActivatedRoute! Here's the relevant piece of code: import { Component } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; declare var module: { id: string; }; @Component({ moduleId: module.id, selector: 'mds-app', templateUrl: 'app.component.html', styleUrls: [ 'app.component.css' ], directives: [] }) export class AppComponent

Angular 2 lazily loaded routes that contain aux router outlet

本小妞迷上赌 提交于 2019-12-18 07:22:25
问题 I'm having an issue with my routing that I'd need a little help with. Originally I had all my routing in a single app.routing.ts file. I'm currently refactoring my routes into a files to accompany their corresponding feature modules to be lazily loaded. One lazily loaded feature module utilizes a secondary aux router outlet. Here is my code.... original : app.routing.ts const appRoutes: Routes = [ { path: 'settings', component: SettingsComponent, children: [ { path: '', redirectTo: '/settings

Angular 2 new Router: How to get router parameters of a child component?

二次信任 提交于 2019-12-18 04:39:14
问题 In the latest version of @angular/router 3.0.0-rc.1 The way you get the parameters from a URL/route changed. Based on this documentation you should be able to get the params by subscribing to the params but in my case it seems that is not working. What I want to achieve is to get params into my parent component FROM child routes. For example let's say this is my routes: const routes: Routes = [ { path: 'parent', component: ParentComponent, pathMatch: 'prefix', children: [ { path: ':id',

Angular2 - ngOnDestroy() not called on similar route

只谈情不闲聊 提交于 2019-12-18 04:15:11
问题 I have an Angular2 app with a route like this: { path: '', component: ContentComponent, children: [ { path: 'folder/:folderId', resolve: { currentFolder: CurrentFolderResolver, }, children: [ { path: '', resolve: { folderStructure: FolderStructureResolve, }, component: FolderOverviewComponent, }, { path: 'users', component: UsersComponent, } ] } ] } When navigating from a route like /folder/123 to /folder/456 , Angular will not trigger ngOnDestroy() in the FolderOverviewComponent . Navigating

Serving static html outside Angular4

末鹿安然 提交于 2019-12-18 03:58:27
问题 I am a beginner in Angular 4/ Angular 2. I am building an app which consists of 1) static html files( aboutus.html, pricing.html, contact us.html etc), with corresponding css, js files 2) single page application with complex functionality The first part #1 does not need Angular at all as it's completely static. After login a user comes to #2. From the Angular tutorials that I went through, it seems I need to combine #1 and #2 together and still have to create components etc out of #1, which I

Angular2: How to find out what was previous page url when using angular2 routing

萝らか妹 提交于 2019-12-18 02:40:11
问题 I am developing an angular2 app and I use router. I am in a page /myapp/signup. after signup I navigate the use to /myapp/login. /myapp/login can also be navigated from my home page which is /myapp. So now, when the user users /myapp/login I go back. This can be done by using location.back(). But I dont want to go back when the user is coming from /myapp/signup. So I should check if the user is coming from /myapp/signup and if so, I want to direct it to somewhere else. How can I know the

RangeError: Maximum call stack size exceeded Lazy routing Angular 2

大兔子大兔子 提交于 2019-12-17 23:09:07
问题 I'm trying to implement lazy routing into my app. I have a very big project and when it was at router-deprecated I used AsyncRoute, but now it was removed. So I tried to implement newest lazy loading, but I got an issue RangeError: Maximum call stack size exceeded What I'm doing wrong? I did all code like in instructions. Take a look please EncountersModule import { NgModule } from '@angular/core'; // import { CommonModule } from '@angular/common'; /* --------------- !System modules ---------

Angular2 RouterLink breaks routes by replacing slash with %2F

杀马特。学长 韩版系。学妹 提交于 2019-12-17 20:50:05
问题 Since the latest Angular2 version (2.0.0-beta.14) it is possible to have query parameters that contain multiple slashes, like /foo/bar. This works great, however whenever I use a parameter with multiple slashes within a RouterLink link, it escapes the / with %2F causing the routes to not work anymore on reload. My link looks like this: <a [routerLink]="['/Page', {page: page.url | slug}]" class="list-group-item">{{ page.title }}</a> Inside of the 'slug' pipe I even URIDecode the string, and