2015-12-18 32 views
0

我正在尝试Angular 2的英雄之旅教程。问题是运行'npm install'后配置如下没有angular.d.ts文件因此我无法导入。我是否使用任何依赖关系的错误版本?没有angular.d.ts文件与Tour of Heroes Angular 2项目

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"] 
} 
+0

使用 进口{组件,查看,进样,注射,提供}从“angular2 /核心“; 从'angular2/platform/browser'导入{bootstrap}; –

+0

,因为在angular2 beta导入中已经如上所述在注释中进行了更改。 –

+0

CORE_DIRECTIVES,FORM_DIRECTIVES在angular2/core中不可用我在哪里从'angular2/common'中导入它们的值为 – tech74

回答

3

所有进口的列表更新为angular2 beta0.0

import {Component, View, Directive, Input, Output, Inject, Injectable, provide} from 'angular2/core'; 

import {bootstrap} from 'angular2/platform/browser'; 

import {CORE_DIRECTIVES, FORM_DIRECTIVES, NgClass, NgIf NgForm, 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' 

如果我增加更多一些这个答案的详细信息,然后个FORM_DIRECTIVES包括以下指令:

NgControlNameNgControlGroupNgFormControlNgModel, ​​,NgFormNgSelectOptionDefaultValueAccessorCheckboxControlValueAccessorSelectControlValueAccessorNgRequiredValidator

更新2

作为angular2的是RC所以在这里所有进口重大更改是在列表中,如果所有更新进口 -

angular2/core -> @angular/core 
angular2/compiler -> @angular/compiler 
angular2/common -> @angular/common 
angular2/platform/common -> @angular/common 
angular2/common_dom -> @angular/common 
angular2/platform/browser -> @angular/platform-browser-dynamic 
angular2/platform/server -> @angular/platform-server 
angular2/testing -> @angular/core/testing 
angular2/upgrade -> @angular/upgrade 
angular2/http -> @angular/http 
angular2/router -> @angular/router 
angular2/platform/testing/browser -> @angular/platform-browser-dynamic/testing 
+0

是的,更新导入。现在它处于测试阶段,这些更稳定。您还可以在angular.io存储库中找到最新的ToH代码,并在其中更新它们。 –