angular2-routing

Migrating from router-deprecated 2.0.0-rc.2 to router@3.0.0-rc.1

ぐ巨炮叔叔 提交于 2019-12-12 21:11:12
问题 I started learning Angular2 back in June when the angular.io quickstart and the "tour of heroes" (tutorial) were based on router-deprecated and the old main.ts-syntax (now we have ngModules). I have problems in upgrading both things: Using ngModule (app.module.ts) and using the new router. Error: http://localhost:3000/traceur Failed to load resource: the server responded with a status of 404 (Not Found) localhost/:22 Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:3000

Feature modules routing with same parent layout angular

守給你的承諾、 提交于 2019-12-12 19:09:54
问题 I want to use same layout (that is defined in app.module.ts ) for different feature modules, each module has its own routing. And a separate login/register layout that would not have side menu, header and footer. So far i tried this: //../app/app.component.html <router-outlet></router-outlet> // here i want login and layout view. and a layout component: //../app/layout.component.html <header></header> <side-menu></side-menu> <router-outlet></router-outlet> // here i want layout views that

Targeting parent's router-outlet from child component in Angular 2?

…衆ロ難τιáo~ 提交于 2019-12-12 18:29:37
问题 Since Angular 2 Router was frequently updated, the old questions for this topic are no longer valid. I have been searching for a solution to this problem and I have yet to find one... So, my problem is targeting parent's component router-outlet from a child component. For example, we have an AppComponent like this one (root of our app) : import { Component } from '@angular/core'; import { ROUTER_DIRECTIVES } from '@angular/router'; import {HeaderComponent} from './header.component'; import

Error: SyntaxError: Unexpected token <

冷暖自知 提交于 2019-12-12 17:50:52
问题 I am getting this error when I load the application. I have referred the router references : 3.0.0-beta.1 The error in the browser console on the loading of the application index.html:24 Error: SyntaxError: Unexpected token < at Object.eval (http://localhost:49928/app/main.js:7:36) at eval (http://localhost:49928/app/main.js:14:4) at eval (http://localhost:49928/app/main.js:15:3) Evaluating http://localhost:49928/lib/@angular/platform-browser-dynamic/platform-browser-dynamic.umd.js Evaluating

Angular 2 router paths

荒凉一梦 提交于 2019-12-12 17:41:54
问题 i have 2 questions regarding Angular 2 router paths, i've spent some time googling about it, but with no luck, anyways i have following routes setup: { path: 'contract', component: ContractInsertUpdateComponent, children: [ { path: '' }, { path: ':id', component: ContractInsertUpdateComponent, children:[ { path: 'buyers', component : ContractTabBuyerComponent }, { path: 'seller', component : ContractTabSellerComponent } ]} ]} First of all, let me explain what i'm trying to achieve here, i

data binding failed in ng2-select

放肆的年华 提交于 2019-12-12 17:34:34
问题 I am trying to bind array of object to dropdown using ng2-select.It works fine when I tried using array of string private category: Array<object> = [{ "value": 1, "text": "Table" }, { "value": 2, "text": "Chair" }, { "value": 3, "text": "Light"}] and my html as follow: <ng-select [items]="category" [allowClear]="true" placeholder="No country selected"> </ng-select> I have also Imported selectModule in my module.ts 回答1: Format of your data is not correct. Instead of: private category: Array

Angular 2 router Error: Uncaught (in promise): TypeError: Cannot read property 'resolve' of undefined

一世执手 提交于 2019-12-12 16:35:06
问题 I am getting the following error when trying to use the router in angular 2: Error: Uncaught (in promise): TypeError: Cannot read property 'resolve' of undefined and I can't figure out what's wrong with my code. Any help is really appreciated. I have the following files main.ts import {bootstrap} from 'angular2/platform/browser'; import {AppComponent} from './app.component'; bootstrap(AppComponent); app.component.ts import { Component } from 'angular2/core'; import { RouteConfig, ROUTER

navigate and navigateByUrl not working correctly in ngOnInit on 2.0.0-rc.1

我的梦境 提交于 2019-12-12 15:26:20
问题 Since the 2.0.0-rc.1 router.navigate or router.navigateByUrl doesn't seem to be working anymore correctly when used inside ngOnInit . I don't get an error or anything, but it looks like the navigate happens too early, because right after it the HomeComponent is loaded and "replaces" the content of the LetterComponent . However the URL is correct ( /letter ). If I put the navigate in a setTimeout with 1000ms it works again. Do I need to use a different lifecycle event or am I doing something

Angular2 - changing location without triggering a Route

荒凉一梦 提交于 2019-12-12 13:12:22
问题 I have a view which uses service to load a list of items. I'm always displaying only one item, moving between items with << >> buttons. Is there any way to change address in browser's address bar and to add record to browser's history without triggering Angular's routing system? I know that if I use: location.go('users/3'); it will do above-mentioned things, but it also triggers Angular's route system, which in turn calls my services again. Edit: it seems like location's function location

How to Set Route params imperatively in named outlets in Angular 2

微笑、不失礼 提交于 2019-12-12 12:07:01
问题 To set imperatively a route param in a router-outler we do: this.router.navigate(['/hero', hero.id]); How do I imperatively set a route parameter in named outlets ? this.router.navigate([{ outlets:{modal: 'modal/user'} }]); Right now I concatenate string to set a route param: this.router.navigate([{ outlets: {modal: 'modal/user' + '/' + 'this.id'} }]); 回答1: make sure your routing file have :id in modal component like this in mine { path: 'component-aux/:id', component: ComponentAux, outlet: