未找到Angular 2.2.0 platform-b​​rowser-dynamic bootstrap

时间:2016-11-19 11:59:14

标签: javascript css angular angular-ui-bootstrap

我习惯用plattform-b​​rowser-dynamic 2.0.0导入bootstrap 像这样:

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

现在我创建新的Projekt并使用角度释放2.2.0 Plattform-b​​rowser-dynamic软件包的版本为2.2.0:

 "@angular/common": "~2.2.0",
    "@angular/compiler": "~2.2.0",
    "@angular/core": "~2.2.0",
    "@angular/forms": "~2.2.0",
    "@angular/http": "~2.2.0",
    "@angular/platform-browser": "~2.2.0",
    "@angular/platform-browser-dynamic": "~2.2.0",
    "@angular/router": "~3.2.0",
    "@angular/upgrade": "~2.2.0",
    "angular-in-memory-web-api": "~0.1.15"

我尝试使用包2.0.0导入bootstrap,但是找不到它。 我的代码:

import { bootstrap } from '@angular/platform-browser-dynamic/*';
import {AppComponent} from "./app.component";
bootstrap(AppComponent);

ERROR:

错误TS2305:模块'" ../ node_modules / @ angular / platform-b​​rowser-dynamic / index"'没有导出的成员' bootstrap'。

我该如何解决?我找不到类似的lib。

1 个答案:

答案 0 :(得分:5)

根据角度最终版本,您可以使用bootstrap platformbrowser方法bootstrapModule您的应用模块。另外,您需要为您的应用程序创建自己的模块。

<强> app.module.ts

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

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

@NgModule({
  imports:      [ BrowserModule ],
  declarations: [ AppComponent ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }

<强> main.ts

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';

platformBrowserDynamic().bootstrapModule(AppModule);

Plunkr Demo