I'm trying to boot up basic Angular 2 (beta 2) app with TypeScript. I have the following app.ts
file (copied from Angular's latest setup guide)
import {Component, View, bootstrap} from 'angular2/angular2';
@Component({
selector: 'app'
})
@View({
template: `
<div></div>
`
})
class AppComponent {
constructor() {}
}
bootstrap(AppComponent);
but when I try to compile it, I get error
Error TS2307: Cannot find module 'angular2/angular2'.
If I instead use the format found on some other resources with angular2/core
instead of angular2/angular2
like
import {Component, View, bootstrap} from 'angular2/core';
I get error
Error TS2305: Module '"node_modules/angular2/core"' has no exported member 'bootstrap'.
What should I do to import all of them?
The bootstrap was moved from angular2/angular2
to angular2/platform/browser
so you need to use it as
import {Component, View} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
As of Angular2 alpha-53
list of imports has been changed from normal angular2/angular2
Since Angular2 alpha-53
bootstrap
can be imported from angular2/platfrom/browser
.
Here is list of all imports may help to someone else.
import{Component,View,Directive,Input,Output,Inject,Injectable,provide,ElementRef} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
import{CORE_DIRECTIVES,FORM_DIRECTIVES,NgClass,NgIfNgForm,Control,ControlGroup, FormBuilder, Validators} from 'angular2/common';
import{RouteConfig,ROUTER_DIRECTIVES,ROUTER_PROVIDERS,Router,LocationStrategy, HashLocationStrategy} from 'angular2/router';
import {Http, HTTP_PROVIDERS, RequestOptions, Headers, Request, RequestMethod} from 'angular2/http'
Breaking change for import list https://github.com/angular/angular/blob/master/CHANGELOG.md#200-alpha53-2015-12-13
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With