Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 979
Roma Kap Avatar asked Jun 14 '26 09:06

Roma Kap


1 Answers

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

like image 164
Pankaj Parkar Avatar answered Jun 15 '26 22:06

Pankaj Parkar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!