2016-08-08 6 views
2

私はng new myprojectを使用してangular2アプリを作成しました。今では私のアプリをブートストラップします。'@ angular/platform/browser'モジュールを見つけることができません

import {bootstrap} from '@angular/platform/browser'; 
import {AppComponent} from './app.component' 
import {ROUTER_PROVIDERS} from '@angular/router' 

bootstrap(AppComponent,[ROUTER_PROVIDERS]); 

は、このファイルの2つの問題があります:だからここに私のboot.tsファイルです 最初の行に'@angular/platform/browser'それは

Cannot find module '@angular/platform/browser'. 

は三行目 import {ROUTER_PROVIDERS} from '@angular/router'にそれが不平を言うと文句を言い:

Module '"c:/Users/Salman/Desktop/Courses/Internship/Angular2/Qminder/Qminder/node_modules/@angular/router/index"' has no exported member 'ROUTER_PROVIDERS'. 

どうすれば修正できますか? ng newコマンドに何か問題はありますか?あなたは以下のモジュールからのブートストラップ機能をインポートする必要がありアンギュラリリース候補版4のよう

答えて

2

import { bootstrap } from '@angular/platform-browser-dynamic'; 

あなたが「app.routes.tsを作成する必要があるので、角度の最新バージョンで変更ルータモジュール「次がありますファイル:

import { provideRouter, RouterConfig } from '@angular/router'; 

const routes: RouterConfig = [ 
    { path: 'home', component: HomeComponent }, 
    { path: '**', component: PageNotFoundComponent } 
]; 

export const appRouterProviders = [ 
    provideRouter(routes) 
]; 

次にインポートする必要がある 『appRouterProviders』をし、それを提供し、 『ブートストラップ』方法:

import { bootstrap }   from '@angular/platform-browser-dynamic'; 
import { AppComponent }  from './app.component'; 
import { appRouterProviders } from './app.routes'; 

bootstrap(AppComponent, [ 
    appRouterProviders 
]) 
.catch(err => console.error(err)); 

最新のルータについての詳しい情報はここで見つけることができます:

https://angular.io/docs/ts/latest/guide/router.html

関連する問題