2016-08-30 8 views
0

はNPMモジュール移行RC4> RC5のトラブルシューティング

main.tsをアルを更新した後、移行に問題がありますapp.components.ts

import { Component } from '@angular/core'; 

import { PartiesListComponent } from './imports/parties/parties-list.component'; 

import template from './app.component.html'; 

@Component({ 
selector: 'app', 
template, 
directives: [ 
PartiesListComponent, 
] 
}) 

export class AppComponent {} 

app.routes.ts:

インポートから{RouterConfig、provideRouter} '@角/ルーター'。

import { PartiesListComponent } from './imports/parties/parties-list.component'; 
import { PartiesFormComponent } from './imports/parties/parties-form.component'; 

const routes: RouterConfig = [ 
{ path: '', component: PartiesListComponent}, 
// { path: 'party/:partyId', component: PartyDetailsComponent }, 
// { path: 'edit/:partyId', component: PartyEditComponent }, 
{ path: 'new', component: PartiesFormComponent}, 
]; 

export const APP_ROUTER_PROVIDERS = [ 
provideRouter(routes) 
]; 

を有する:

無効ルート設定:配列はで 変化によって

答えて

0

指定

が解決解決できませんapp.routes.ts

import { ModuleWithProviders } from '@angular/core'; 
import { Routes, RouterModule } from '@angular/router'; 
....some code..... 
const appRoutes: Routes = [ 
....some code..... 
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes); 

だが持っている:

browser_adapter.js: 93EXCEPTION: 
Error: Uncaught (in promise): TypeError: Cannot read property 'completer' of undefined 
0

変更あなたの次のようにapp.routes.ts

import { Routes } from '@angular/router'; 

import { PartiesListComponent } from './imports/parties/parties-list.component'; 
import { PartiesFormComponent } from './imports/parties/parties-form.component'; 

export const ROUTES: Routes = [ 
    { path: '', component: PartiesListComponent}, 
    { path: 'new', component: PartiesFormComponent}, 
]; 
があなたの app.module.ts以下のように変更し

import { NgModule } from '@angular/core'; 
import { BrowserModule } from '@angular/platform-browser'; 

import { RouterModule } from '@angular/router'; 

import { AppComponent } from './app.component'; 

import { ROUTES } from './app.routes'; 

import { PartiesFormComponent } from './imports/parties/parties-form.component'; 
import { PartiesListComponent } from './imports/parties/parties-list.component'; 

@NgModule({ 
    declarations: [ 
    AppComponent, 
    PartiesFormComponent, 
    PartiesListComponent 
    ], 
    bootstrap: [AppComponent], 
    imports: [ 
    BrowserModule, 
    RouterModule.forRoot(ROUTES, {useHash: true}), 
    ]  
}) 
export class AppModule { } 
関連する問題