angular2-routing

Angular 2 CLI App throwing 404 errors once deployed

笑着哭i 提交于 2019-12-12 03:53:40
问题 I recently updated an app I've been working on to latest version of Angular CLI (currently beta25). Using ng serve all routing works perfectly locally. I then use ng build --prod, zip up the dist directory and load it to my web server (currently hosted on AWS Tomcat). When I navigate index.html, I'm using a default route to drop into a "home" component. Everything works to that point. If I refresh the browser, however, I get a 404. Additionally any direct and deep link navigation I attempt to

Cannot match any routes: ''

╄→尐↘猪︶ㄣ 提交于 2019-12-12 03:47:27
问题 I have a defined route in angular2 application and receive such error: Cannot match any routes: '' export const routes: Routes = [{ path: '', component: MainComponent, children: [{ path: 'callCenter', component: CallCenterComponent, resolve: { countries: CountriesResolver }, }, { path: 'vehicle', component: VehicleComponent, resolve: { vehicleCategories: VehicleCategoryResolver, vehicleOptions: VehicleOptionResolver }, }, { path: 'territory', component: TerritoryComponent, resolve: {

body content has to be update without header and footer change and no page refresh

一笑奈何 提交于 2019-12-12 03:43:24
问题 I have a header menu with buttons "home" and "about us". By default home page loads. In the home page, i have a link in the home page. when i click on the link on the home page or "about us" button, the body content has to be changed in the home page but page should not be refresh. "About us" related data has to be display. Header and footer page is common for all pages and only body content has to be updated without page refresh. I don't want to use any jquery or no server call here. 回答1:

Router Parameter in Angular2

老子叫甜甜 提交于 2019-12-12 03:36:58
问题 The problem is that router parameters are showing in URL while I want my router parameter not to show in URL ? myComponent.ts @RouteConfig([ { path: '/routerOne/:myId', component: routerOne, name: "routerOne",useAsDefault: true}, { path: '/routerTwo/:myId', component: routerTwo, name: "routerTwo"}, ]) myComponent.html <a [routerLink]="['routerOne',{myId:this.Id}]">RouterOne</a> <a [routerLink]="['routerTwo',{myId:this.Id}]">routerTwo</a> 回答1: As of now sharedService can be the last option as

@Input binding doesn't work when I put it under a router component

孤人 提交于 2019-12-12 03:35:15
问题 Updated Answer I've just found out what happened. I have to load the script pollyfills after systemjs . Well, this is an known issue of the router: Concat/Load Order 'node_modules/systemjs/dist/system.src.js', 'node_modules/angular2/bundles/angular2-polyfills.js' Problem I am trying to use my own component library in my app. After I put the component under a page inside a router component, the component's title decorated with @Input doesn't show up: I need it renders the title properties

Angular 2 : Redirect to a page at application startup

爷,独闯天下 提交于 2019-12-12 03:28:25
问题 I'm facing a little issue for my web application in Angular 2. Each application launch, I would check if the user has a right of access. However I don't know how to redirect the user to the route which makes this process whatever the place where he is. Any ideas? Thanks in advance! 回答1: There are two common ways use CanActivate use a custom RouterOutlet where you check if the user is authenticated otherwise redirect to the login route See also - Check if the user logged in on any page change

angular2 rc1: No provider for RouterOutletMap

送分小仙女□ 提交于 2019-12-12 03:22:23
问题 I created a subcomponent within a component. I also created the according routes. Now after I did this, the test that was originally created by angular-cli fails with: No provider for RouterOutletMap! Is there any general reason for this error-message? I could always post the whole component-sourcecode, but that seems overkill at this point :-) Edit: I am using the new router (rc1) 回答1: Make sure you have used following 5 points in your main AppComponent- import { ROUTER_PROVIDERS, Routes,

Loading router's paths from external files

♀尐吖头ヾ 提交于 2019-12-12 03:04:59
问题 I' trying to build an app that can be used from different country in different language. The idea is to have paths that uses good keywords for SEO in each country. The json file loaded depends on the path url: /uk, /fr, /es loads uk.js, fr.js or es.js So I'm trying to do something like this : root.rooting.ts import {Routes, RouterModule} from '@angular/router'; const base = document.location.pathname.split('/')[1]; const paths = require('./' + base + '.js'); const appRoutes: Routes = paths;

Angular 2 rc3 routing issues

时光总嘲笑我的痴心妄想 提交于 2019-12-12 03:03:12
问题 I think I have followed directions to get routing in rc3 working. It works well in rc1. I create the app.routes, the app.providers, and it looks like this: main.ts: import {bootstrap} from '@angular/platform-browser-dynamic'; import {APP_ROUTER_PROVIDER} from './app.routes'; import {HTTP_PROVIDERS} from '@angular/http'; import {AppComponent} from './app.component'; bootstrap(AppComponent, [APP_ROUTER_PROVIDER, HTTP_PROVIDERS]); app.component.ts: import {Component, OnInit} from '@angular/core'

Angular 2 routing - disable, redirect, translation

≯℡__Kan透↙ 提交于 2019-12-12 02:37:11
问题 In my Angular 2 app I have this Route config. @RouteConfig([ { path: '/', name: 'Welcome', component: WelcomeComponent, useAsDefault: true }, { path: '/ticket', name: 'Ticket', component: TicketComponent }, { path: '/payment', name: 'Payment', component: PaymentComponent }, { path: '/receipt', name: 'Receipt', component: ReceiptComponent }, { path: '/login', name: 'Login', component: LoginComponent }, { path: '/services', name: 'Services', component: ServicesComponent }, { path: '/email',