Angular2 TypeScript - 错误 TS2307:找不到模块 'angular2/core'
Angular2 TypeScript - error TS2307: Cannot find module 'angular2/core'
我的 TypeScript 版本 1.7.5
我的主要组件文件
// import {Component} from 'angular2/core';
import {Component, View} from 'angular2/core';
// import {bootstrap} from 'angular2/platform/browser';
@Component({
selector: 'my-app',
// template: '<h1>My title: {{title}}</h1> <h2>Hardcoded h2</h2>'
})
@View({
templateUrl: '/templates/home.html',
directives: []
})
.Class({
constructor: function() {
}
})
export class AppComponent {
title = "My First Angular 2 App";
}
我的 HTML 个脚本
<!-- 1. Load libraries -->
<script src="node_modules/es6-shim/es6-shim.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src='app.component.js'></script>
<script src='app/boot.js'></script>
接下来当我尝试编译文件时tsc app.component.ts --module system --experimentalDecorators
我收到以下错误: app.component.ts(2,31): error TS2307: Cannot find module 'angular2/core'.
你知道我在这里错过了什么吗?
删除:
.Class({
constructor: function() {
}
})
删除:
@View({
templateUrl: '/templates/home.html',
directives: []
})
并将 templateUrl: '/templates/home.html',
放在 @Component 注释中。
并应用 system.js
配置。
通常按照此处的步骤操作:
检查第二个例子。
我的 TypeScript 版本 1.7.5
我的主要组件文件
// import {Component} from 'angular2/core';
import {Component, View} from 'angular2/core';
// import {bootstrap} from 'angular2/platform/browser';
@Component({
selector: 'my-app',
// template: '<h1>My title: {{title}}</h1> <h2>Hardcoded h2</h2>'
})
@View({
templateUrl: '/templates/home.html',
directives: []
})
.Class({
constructor: function() {
}
})
export class AppComponent {
title = "My First Angular 2 App";
}
我的 HTML 个脚本
<!-- 1. Load libraries -->
<script src="node_modules/es6-shim/es6-shim.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src='app.component.js'></script>
<script src='app/boot.js'></script>
接下来当我尝试编译文件时tsc app.component.ts --module system --experimentalDecorators
我收到以下错误: app.component.ts(2,31): error TS2307: Cannot find module 'angular2/core'.
你知道我在这里错过了什么吗?
删除:
.Class({
constructor: function() {
}
})
删除:
@View({
templateUrl: '/templates/home.html',
directives: []
})
并将 templateUrl: '/templates/home.html',
放在 @Component 注释中。
并应用 system.js
配置。
通常按照此处的步骤操作:
检查第二个例子。