我正在使用Angular2和Gulp开发一个Node应用程序。我已经编写了一个组件文件login.ts,内容如下:
import {Component, View} from 'angular2/angular2';
import {FormBuilder, formDirectives } from 'angular2/forms';
@Component({
selector: 'login',
injectables: [FormBuilder]
})
@View({
templateUrl: '/scripts/src/components/login/login.html',
directives: [formDirectives]
})
export class login {
}
我的 bootstrap.ts 文件是:
import {bootstrap} from 'angular2/angular2';
import {login} from './components/login/login';
bootstrap(login);
但是当我编译这些文件时,它给出以下错误:
client\bootstrap.ts(1,25): error TS2307: Cannot find module 'angular2/angular2'.
client\components\login\login.ts(1,31): error TS2307: Cannot find module 'angular2/angular2
client\components\login\login.ts(2,45): error TS2307: Cannot find module 'angular2/forms'.
这是我的tsconfig.json文件:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true,
"watch": true,
"removeComments": true,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true
}
}
我已经使用以下方式安装了用于 Angular2 的打字效果:
tsd install angular2 --save
请帮忙修复错误。
<script src="https://code.angularjs.org/<version>angular2.dev.js">
),那么您将从'angular2'导入。如果您正在从npm安装angular2作为依赖项,则应导入'@angular'。此外,Angular2目前处于rc4阶段,正在发生许多变化。为了获取Angular2的最新更改,我建议查看angular.io网站上的5分钟快速入门。 - kimbaudi