我正在尝试使用TypeScript启动基本的Angular 2(beta 2)应用程序.我有以下app.ts文件(从
Angular’s latest setup guide复制)
import {Component,View,bootstrap} from 'angular2/angular2'; @Component({ selector: 'app' }) @View({ template: ` <div></div> ` }) class AppComponent { constructor() {} } bootstrap(AppComponent);
但是当我尝试编译它时,我得到了错误
Error TS2307: Cannot find module ‘angular2/angular2’.
如果我改为使用在angular2 / core而不是angular2 / angular2之类的其他资源上找到的格式
import {Component,bootstrap} from 'angular2/core';
我收到错误
Error TS2305: Module ‘”node_modules/angular2/core”‘ has no exported member ‘bootstrap’.
我应该怎么做才能导入所有这些?
解决方法
引导程序从angular2 / angular2移动到angular2 / platform / browser,因此您需要将其用作
import {Component,View} from 'angular2/core'; import {bootstrap} from 'angular2/platform/browser';