angular2-routing

Angular 2 routing raising 404 errors

£可爱£侵袭症+ 提交于 2020-01-01 15:48:04
问题 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. 回答1: EDIT : IIS Setup for Url Rewriting: You need to install this to make the following work: http://www.iis.net

How to preload angular2 views so will not flicker white page on first load?

对着背影说爱祢 提交于 2020-01-01 10:28:15
问题 I am building an angular 2 app in plain JS. My problem is that when I change from a page to another it flicker a white page until the new view is rendered. This happens for all components only first time I access them. If I go to same route second time the page is loaded without white page. I capture the screen to explain better my problem: https://drive.google.com/file/d/0B5pOsXT-4rdTbmtuVnlUdXRMdE0/view?usp=sharing Here is my main view: <router-outlet></router-outlet> <nav id="menu"> <a

Angular 2: How do I get params of a route from outside of a router-outlet

痴心易碎 提交于 2020-01-01 10:00:35
问题 Similar question to Angular2 Get router params outside of router-outlet but targeting the release version of Angular 2 (so version 3.0.0 of the router). I have an app with a list of contacts and a router outlet to either display or edit the selected contact. I want to make sure the proper contact is selected at any point (including on page load), so I would like to be able to read the "id" param from the route whenever the route is changed. I can get my hands on routing events by subscribing

Angular 2: How do I get params of a route from outside of a router-outlet

ε祈祈猫儿з 提交于 2020-01-01 10:00:11
问题 Similar question to Angular2 Get router params outside of router-outlet but targeting the release version of Angular 2 (so version 3.0.0 of the router). I have an app with a list of contacts and a router outlet to either display or edit the selected contact. I want to make sure the proper contact is selected at any point (including on page load), so I would like to be able to read the "id" param from the route whenever the route is changed. I can get my hands on routing events by subscribing

Angular 2 Lazy loading a NgModule in a NPM module with angular router

邮差的信 提交于 2020-01-01 09:25:30
问题 I have been lazy loading modules in routes e.g. export const HomeRoute: Route = { path: '', component: HomeComponent, canActivate: [AuthGuard], children: [ {path: 'dashboard', loadChildren: 'app/+dashboard/db.module#DashboardModule'} ] }; I would like to put my "pages" into NPM modules. What is the route to the node_module that I should use in the loadChildren attribute? I am using angular-cli 1.0.0-beta.16 I have tried {path: 'lazy', loadChildren: '../node_modules/hello-world/components

Argument of type '{header:Header;}' is not assignable to parameter of type 'RequestOptionsArgs'

我怕爱的太早我们不能终老 提交于 2020-01-01 05:22:06
问题 Im Getting following error while trying to pass header in HTTP.POST/GET request Argument of type '{header:Header;}' is not assignable to parameter of type 'RequestOptionsArgs'. Property 'null' is missing in the type '{header:Header;}' I have try many solutions but no lock on it. here my code : import { Injectable } from '@angular/core'; import { Response, RequestOptions, Headers, Http, URLSearchParams} from '@angular/http'; import { Observable, Subject } from 'rxjs/Rx'; import {Company} from

Angular 2 routes in imported module override current

时光毁灭记忆、已成空白 提交于 2019-12-31 10:01:28
问题 Here's the plunker: https://plnkr.co/edit/WIFNVIEVqls4gXk21Muj There're 2 modules both have routes defined. Module 2 imports module 1 in order to use a component from it. You can never navigate to Module 2. Module 1 loads instead. Module 1 routing: const routes: Routes = [ { path: '', component: Module1Component } ]; Module 2 routing: const routes: Routes = [ { path: '', component: Module2Component } ]; App routing: const routes: Routes = [ { path: 'module1', loadChildren: 'app/module1

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

Angular2 redirect to custom error page

一曲冷凌霜 提交于 2019-12-30 22:53:51
问题 I've implemented my custom error handler, and in that I want to re-direct to my custom error page that just says "sorry, an error occurred......". I declared a route under my app-routing.module.ts file like this: import { NgModule } from '@angular/core'; import { PreloadAllModules, Routes, RouterModule } from '@angular/router'; import { NoContentComponent } from './no-content/no-content.component' import { CustomErrorComponent } from './customerror/customerror.component'; const routes: Routes