Roma Kap
Roma Kap

Reputation: 636

Angular 2.2.0 platform-browser-dynamic bootstrap not found

i am used to import bootstrap by plattform-browser-dynamic 2.0.0 like this:

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

Now i create new Projekt and use angular release 2.2.0 Plattform-browser-dynamic packages has version 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"

I try same like with package 2.0.0 to import bootstrap, but it will not be found. My code:

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

ERROR:

error TS2305: Module '"../node_modules/@angular/platform-browser-dynamic/index"' has no exported member 'bootstrap'.

How can i fix that? i cant find some similar lib.

Upvotes: 3

Views: 4141

Answers (1)

Pankaj Parkar
Pankaj Parkar

Reputation: 136144

As per angular final release you can bootstrap your application module using platformbrowser's bootstrapModule method. Additonally you need to create your own module for your App.

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

Upvotes: 4

Related Questions