angular2-routing

EXCEPTION: Uncaught (in promise): Error: Cannot find module 'app/home/home.module'

做~自己de王妃 提交于 2019-11-30 02:13:54
问题 I'm trying to lazy load Angular 2 modules with the router, and I'm having this error: error_handler.js:50 EXCEPTION: Uncaught (in promise): Error: Cannot find module 'app/home/home.module' I tried all the answers that seems to be working for the others, like this one which seems to be a solution for everybody facing this issue, but doesn't work with me Lazy loading in Angular2 RC7 and angular-cli webpack here is my code: app.module import { MediatorService } from './home/mediator.service';

Angular 2 access base href [duplicate]

风流意气都作罢 提交于 2019-11-30 01:25:39
问题 This question already has answers here : How do I get the absolute path of the current page in Angular 2? (4 answers) Closed 3 years ago . I have a code in my solution which gets baseHref of an app constructor( private router: Router) { let baseHref = this.router._location._baseHref; You could see what I am getting it via private properties. Is there other way to get base url? aka the url before router added it's parts? I am using angular2 rc4 Thanks 回答1: The Location class has

Different routes same component

て烟熏妆下的殇ゞ 提交于 2019-11-30 01:18:19
问题 I want to achieve something like this /products shows all the products and /products/:category shows all the products related to a specific category. To achieve that I have the following routes: const productsRoutes: Routes = [ { path: 'products', component: ProductsComponent, children: [ { path: '', component: ProductsListComponent, }, { path: ':category', component: ProductsListComponent } ] } ]; Problem When I switch between categories, everything is fine, when I switch between all

Does angular2 support nested states/routes?

末鹿安然 提交于 2019-11-30 01:13:42
Does angular2 support nested states/routes? for example in a view port there are 2 links and on clicking a specific link it will present a view which with further have more than one link but that are specific to earlier link. Namek Yes. I made some demo: http://plnkr.co/edit/IcnEzZ0WtiaY5Bpqrq2Y?p=preview import {Component, View, Input} from 'angular2/core'; import { RouteConfig, Router, RouteParams, ROUTER_DIRECTIVES } from 'angular2/router'; import {PersistentRouterOutlet} from './persistent-router-outlet'; @Component({}) @View({ template: 'product info here' }) class ProductInfo { }

Angular 2 - Check current active route “name”

情到浓时终转凉″ 提交于 2019-11-30 00:29:06
I am having an Angular 2 application with several nested children view. But it will be displayed on the same page though several router-outlet . const routes: Routes = [ { path: 'queue/:date/:offset/:type', component: BundleListComponent, resolve: { response: BundleListResolve }, children: [ { path: ':bundleId', component: PointListComponent, resolve: { response: PointListResolve }, children: [ { path: ':pointId', component: TaskListComponent, resolve: { response: TaskListResolve }, children: [ { path: ':taskId', component: TaskDetailComponent, resolve: { response: TaskDetailResolve } }, {

Angular2 RC6 - Nested modules with routing

此生再无相见时 提交于 2019-11-29 22:38:52
In my application I have a SupportModule which has 3 sub-Modules ( AdminModule , ChatModule , ContactModule ). SupportModule and its 3 sub-Modules have their own routings define. Structure looks something like The routing for the `AdminModule' is given below: import { AdminComponent } from './admin.component'; import { RssFeedsComponent } from './rssFeeds.component'; import { RssFeedDetailComponent } from './rssFeedDetail.component'; export const adminRoutes: Route = { path: 'admin', component: AdminComponent, children: [ { path: '', component: RssFeedsComponent }, { path: 'feeds', component:

Angular 2 reload route on param change

痞子三分冷 提交于 2019-11-29 21:22:27
I am currently writing my first Angular 2 Application. I have an OverviewComponent which has the following simple template: <div class="row"> <div class="col-lg-8"> <router-outlet></router-outlet> </div> <div class="col-lg-4"> <app-list></app-list> </div> </div> when accessing the url / my router redirects me to /overview which then loads a map within the router-outlet. The <app-list> has a list of clickable items which triggers a <app-detail> to be displayed instead of the app component. Therefor I pass the id of the referring json file in the url like that: /details/:id (in my routes). All

Angular 2 How to redirect to 404 or other path if the path does not exist [duplicate]

这一生的挚爱 提交于 2019-11-29 20:14:37
This question already has an answer here: Handling 404 with Angular2 1 answer I was trying to redirect 404 / other path if the path does not exist in angular 2 I tried research there is some method for angular 1 but not angular 2. Here is my code : @RouteConfig([ { path: '/news', name: 'HackerList', component: HackerListComponent, useAsDefault: true }, { path: '/news/page/:page', name: 'TopStoriesPage', component: HackerListComponent }, { path: '/comments/:id', name: 'CommentPage', component: HackerCommentComponent } ]) So example if I redirect to /news/page/ then it works and it return me an

Angular2 - two components with the same route

蓝咒 提交于 2019-11-29 19:15:36
问题 In angularJS ui-router allows us to use 2 components with the same route using states (like in this example Angular UI Router: Different states with same URL?). Is it possible to achieve the same behaviour in angular2? If it is could you link/provide some examples or workarounds? The use case here would be something similar to Facebook or Twitter where the URL stays the same but the content changes depending on if you are logged in or not. So far the only way I can think off to achieve this

How to handle hash fragments from oauth redirect urls in Angular2 rc3 routing

戏子无情 提交于 2019-11-29 18:27:45
问题 I'm trying to find a way to handle setting up an Angular2 Typescript route (using the 3.0.0-alpha.8 router) that will handle routes that begin with hash fragments. The app I'm working on handles all login externally (something I have no control over) through a rails backend with oauth2. Redirecting users to the external login page works fine but when the redirect url, always some form of http://localhost:4200#access_token=TOKEN (where TOKEN is a series of numbers and letters) is sent back but