angular2-routing

Cannot read property 'outlets' of null

好久不见. 提交于 2019-12-04 16:11:12
问题 I have next problem : Cannot read property 'outlets' of null . My project works, but after some time it stopped working, but i didn't change my code. Help me please. Update My component with router-outlet: import { Component } from '@angular/core'; @Component({ selector: 'app', template: ' <nav-menu></nav-menu> <router-outlet></router-outlet> <footer-component></footer-component> ', }) export class AppComponent {} app.module: import { NgModule } from '@angular/core'; import { BrowserModule }

Angular 2.0.0-rc3: partial route matching with routerLinkActive

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 15:57:50
I'm using routerLinkActive in my primary routing. <a [routerLink]="/user" routerLinkActive="active">Bob</a> When the URL is /user , the active class will be added to the a tag, but under the primary route, I also have a few secondary routes, so when the URL is /user/aa , the active will be removed. I hope that when the URL is either /user/aa or /user/bb , the primary route's class active still exists. What should I do? Add [routerLinkActiveOptions]="{ exact: false }" As far as I know this is going to be the default with the next update. 来源: https://stackoverflow.com/questions/38090949/angular

Angular 2: NavigationCancel - Navigation ID 2 is not equal to the current navigation id 3

时光毁灭记忆、已成空白 提交于 2019-12-04 15:37:33
问题 I'm trying to redirect old URLs (links in email templates) from a previous site to another route like this: if (route.url.indexOf('/#/') !== -1) { this.router.navigate(['/my-route']); } However, the navigation gets cancelled with the following reason: Navigation ID 2 is not equal to the current navigation id 3 . Looking at the Angular 2 router source, this happens in the runNavigate method when id !== this.navigationId (https://github.com/angular/angular/blob/master/modules/@angular/router

How to separate admin and the front web in angular 2 project

空扰寡人 提交于 2019-12-04 14:19:07
问题 I'm going to build a full project using angular 2, the project contains admin panel and a front-end web for users. I don't know how to separate admin from the web, should I use routing for this? But this will require me to import all components inside the app.module.ts or there is another way to use two app.module.ts one for the web and one for the admin? Or what should I do? 回答1: I've built this recently and what I did was simply to split the routes into two different modules. So you'd have

Angular 2 Dynamic Page Header and Footer

天大地大妈咪最大 提交于 2019-12-04 13:54:29
The following is what is included in my app.component.html <lmenu></lmenu> <header></header> <router-outlet></router-outlet> <footer></footer> However my login and register pages are both rendered through this module and they only require the router-outlet. How an dynamically not include the lmenu, header, and footer selectors for the login and register views? Thanks in advance. <lmenu *ngIf="isLogin"></lmenu> <header *ngIf="isLogin"></header> <router-outlet></router-outlet> <footer *ngIf="isLogin"></footer> Just switching isLogin between true and false shows/hides the components you could use

Angular 2 routing raising 404 errors

落爺英雄遲暮 提交于 2019-12-04 13:10:19
HTML5 PushState means refresh URL or enter direct URL in browser works perfectly fine when I run my angular app using 'npm start' command from VS 2015 command prompt. However when I deploy same application on IIS and change <base href="/"/> to <base href="/MyVirtualApplication/" /> then HTML5's PushState or History API doesn't work properly and raising 404 error. Please do suggest. Bryan EDIT : IIS Setup for Url Rewriting: You need to install this to make the following work: http://www.iis.net/downloads/microsoft/url-rewrite First Step: Second Step: I found a link which explains the solution:

Angular 2 - Named router outlets without horrible URLs

陌路散爱 提交于 2019-12-04 12:35:25
问题 I want to have two router outlets, the primary one, and a modal outlet. When navigating to /login , I want to show my home component in the primary outlet, and my login component in the modal outlet. Something like this: { path: 'login', component: HomeComponent }, { path: 'login', component: LoginComponent, outlet: 'modal' } This is possible to do by using horrible auxiliary URLs like /home(modal:login) , but of course no one wants their URLs to look like that. How do I solve this without

Angular 4 losing subscription with router paramMap using switchMap

℡╲_俬逩灬. 提交于 2019-12-04 12:33:54
Using the latest version of Angular I have a very small, simple application - see below: The forecast detail component looks like the following: public getForecastData(forecastId) : Observable<any> { return this.http.get<any>('/api/forecasts/' + forecastId + '/data'); } ngOnInit() { this.route.paramMap .switchMap( params => { return this.getForecastData(params.get('id')) }) }) .subscribe( (data) => { // business logic here }); The issue I'm having is that if the getForecastData call fails (server returns 500) the subscription to the router paramMap observable seems to be lost. I try navigating

Angular2 @angular/router 3.0.0-alpha.3 - How to get route name or path when route changes

北慕城南 提交于 2019-12-04 12:31:50
问题 I'm trying to get the current route name or route path in my app.component when the route changes so that I can use the route name as a page class around a wrapper div. I'm trying to figure out the best way to handle this. Previously I was subscribing to the router changes property like I have listed below, but it seems like this is no longer available with @angular/router 3.0.0-alpha.3. If anyone has any thoughts or suggestions I would be most grateful. this.router.changes.subscribe((val) =>

Angular 2+ Application pre loader with percentage indicator

这一生的挚爱 提交于 2019-12-04 12:21:07
问题 Does anyone know the good solution for implementing Angular 2+ pre loader with percentage indicator ( Similar to Gmail's loading screen )? I know that usual way is to add <div> inside our <app-root> and style it, maybe even add CSS animations and it will be replaced by app content once app is loaded. But... What I am actually looking is to display animated splash screen ( SVG or whatever else ) where after animation completes loading bar should appear and show progress status. At first point