【发布时间】:2016-03-25 02:17:05
【问题描述】:
我正在尝试 Angular 2 的英雄之旅教程。问题是在使用如下配置运行“npm install”后没有 angular.d.ts 文件因此我无法导入。我是否使用了错误版本的任何依赖项?
import {bootstrap, CORE_DIRECTIVES, FORM_DIRECTIVES, OnInit} from 'angular2/angular2';
package.json
{
"name": "angular",
"version": "1.0.0",
"scripts": {
"tsc": "tsc",
"tsc:w": "tsc -w",
"lite": "lite-server",
"start": "concurrent \"npm run tsc:w\" \"npm run lite\" "
},
"license": "ISC",
"dependencies": {
"angular2": "2.0.0-beta.0",
"systemjs": "0.19.6",
"es6-promise": "^3.0.2",
"es6-shim": "^0.33.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.0",
"zone.js": "0.5.10"
},
"devDependencies": {
"concurrently": "^1.0.0",
"lite-server": "^1.3.1",
"typescript": "^1.7.3"
}
}
我的 tsconfig.json
{
"compilerOptions": {
"target": "ES5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": ["node_modules"]
}
【问题讨论】:
-
使用 import {Component, View, Inject, Injectable, provide} from 'angular2/core';从'angular2/platform/browser'导入{bootstrap};
-
因为在 angular2 beta 中导入已更改,如评论中所述。
-
CORE_DIRECTIVES, FORM_DIRECTIVES 在 angular2/core 中不可用我从哪里导入它们
-
从 'angular2/common' 导入 {CORE_DIRECTIVES, NgClass, FORM_DIRECTIVES, NgForm, Control, ControlGroup, FormBuilder, Validators};
标签: angular typescript