angular2-routing

Route without parameter value; Angular route redirect - Can I use redirectTo to parameter path?

邮差的信 提交于 2019-12-07 22:46:32
I'm wandering if it is possible to redirect path: ' ' to path: ':id' ? Is there a way I can achieve this? Thank you. { path: 'folder', children: [ { path: '', redirectTo: ':id', pathMatch: 'full', }, { path: ':id', canActivate: [AuthGuard], component: DocumentsComponent, }, ] } I found a way to redirect 'folder' route to 'folder/:id' with empty 'id' parameter: { path: 'folder', redirectTo: 'folder/', pathMatch: 'full', }, { path: 'folder', children: [ { path: ':id', canActivate: [AuthGuard], component: DocumentsComponent, }, ] } *Note that the redirect must be first. if you give a default id

Angular2 App Routing through Services

…衆ロ難τιáo~ 提交于 2019-12-07 19:16:06
问题 Here's my scenario : Il get straight to the point first... I want to load all the routes including the default route of a app in RouteConfig through a service. I am able to do so but cannot load the default route dynamically, other routes can be loaded dynamically. Suppose i bootstrap(AppComponent) and my AppComponent view only content is <router-outlet></router-outlet> so in this scenario the AppComponent RouteConfig needs to be loaded dynamically i.e in my case i call a service which

Angular 2 get URL from ComponentInstruction

你。 提交于 2019-12-07 14:39:38
问题 I have a custom router-outlet that caches components. The code for that is this: https://gist.github.com/waeljammal/467286d64f59f8340a93#file-persistentrouteroutlet-ts-L75 The code example uses the component type as the cache key - however, I need mine to cache by the URL so that I can cache two different instances of the same component. Is there any way to get the URL based on the ComponentInstruction ? 回答1: So I got this working now. The mistake was that I was applying the

Angular2 Can't resolve all parameters for RouterOutlet: (RouterOutletMap, ViewContainerRef, ?, name)

微笑、不失礼 提交于 2019-12-07 13:42:10
问题 I'm totally new to any JS framework. Just started learning Angular 2. I'm doing some basic app for internship. From angular app I post name to Java controller, that get's info needed and sends it back. Basically fun happens when name is 'Dave' or 'Hal'. All looks fine, but when I run server and try to get to my app, I get EXCEPTION: Error: Uncaught (in promise): Can't resolve all parameters for RouterOutlet: (RouterOutletMap, ViewContainerRef, ?, name). As far as I can tell from documentation

Auth0 and angular2: how to set callbackURL and catch the token?

那年仲夏 提交于 2019-12-07 11:58:29
I am trying to implement passwordless authentication with Auth0 and angular2 (2.0.0-rc.6), using angular2-webpack-starter and auth0-lock-passwordless . The form displays normally, and the authentication e-mail is sent using this code: this.lock.magiclink({ callbackURL:"http://localhost:3000/#/sandbox" }); The issues occur after I click the magic link in the e-mail: Even though the redirect_uri of the magic link seems correct (redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F%23%2Fsandbox), it is ignored; Instead, after a successful login (checked in Auth0 logs), the url in the address bar is

Angular2- When refresh the page, url remains same but appropriate view doesn't get loaded

余生颓废 提交于 2019-12-07 11:32:00
问题 In Angular2, I am facing this issue. When you refresh the page. The URL remains same but it doesn't load appropriate view in RouterOutlet . Everything works fine except refreshing page issue. app.ts import {Component,bind} from 'angular2/core'; import {bootstrap} from 'angular2/platform/browser'; import {FORM_DIRECTIVES} from 'angular2/form'; import{HomeCmp} from 'Angular/src/Home/home.ts'; import {ContactUsCmp} from 'Angular/src/ContactUs/contactus.ts'; import {Router,ROUTER_PROVIDERS

Angular 2 routes not working after building the project

大兔子大兔子 提交于 2019-12-07 10:34:47
问题 These are my routes: import { Routes } from '@angular/router'; import {WelcomeComponent} from "./welcome/welcome.component"; import { LoginComponent } from './login/login.component'; export const routes: Routes = [ {path: '', component: WelcomeComponent}, {path: 'login', component: LoginComponent}, {path: '**', component: WelcomeComponent} ]; I buid my project using ng buid . When I enter a not defined path, I expect the application to redirect to '/' path as it happens during development,

How can I navigate to lazy loaded module child routes?

匆匆过客 提交于 2019-12-07 09:00:34
问题 I am trying to lazy load module with child routes declared in it's routing configuration file, The lazy module loaded successfully but I can't navigate to it's child routes. I am using the technique as if it were a eagerly loaded module. I declared path and inside it it's children. Please see 'moduleB' routing file in the Plunker The link button is trying to navigate to the child route and load CmpC. but it fails. Here is my root module routing decalration: { path: 'feature-b', loadChildren:

Angular 2 - issue with bootstrap nav <li><a href=“#header”></a></li> in routing set up

白昼怎懂夜的黑 提交于 2019-12-07 08:10:29
am trying to converting normal bootstrap page into components in Angular 2. am actually facing issues when constructing navigation. initially the tags <li><a href></a></li> is like below <div id="header" class="shadow"> <!-- Navigation --> <nav> <div class="nav nav-wrapper navbar-fixed-top"> <div class="container-fluid"> <!-- Menu Option --> <ul class="nav-justified hide-on-med-and-down"> <li><a href="#header">About</a></li> <li><a href="#prodcutInfo">Prod.Info</a></li> <div id="side-nav"> <div id="nav-header"> <div id="nav-profile" class="center-block"> <!-- Profile Picture [Square] --> <img

Retrieving the active component and path

我的梦境 提交于 2019-12-07 07:23:42
问题 With Angular2, how would I retrieve the current active component and path? For example I might have the following routes: { path: '', component: HomeComponent }, { path: 'list', component: ListComponent }, { path: ':id/', component: CustomComponent } If I had navigated to https://domain.com/test is there a way to know I'm currently viewing the CustomComponent and to retrieve the id/path, which in this case is "test"? I could use window.location.pathname with regex to get the path but this is