我們試圖啓動與Visual Studio 2015年一個新的Angular2項目我們已經創建了一個新的打字稿項目,下面的例子合作,我們發現我們已經把以下我們index.html
文件:開始與VisualStudio的,打字稿及Angular2
<script src="https://rawgithub.com/systemjs/systemjs/0.19.6/dist/system.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.0/angular2-polyfills.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.0/Rx.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.0/angular2.dev.js"></script>
(sidenode - 爲什麼我們需要許多具有各自的含義,爲什麼沒有他們都在一個單一的基礎文件?)
我們的角度應用程序是這樣的:
import {Component} from 'angular2/core';
@Component({
// Declare the tag name in index.html to where the component attaches
selector: 'hello-world',
// Location of the template for this component
templateUrl: 'app/hello_world.html'
})
export class HelloWorld {
// Declaring the variable for binding with initial value
yourName: string = '';
}
我們希望爲絕對型的angular2添加一個類型文件,但好像是空的(https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/angular2/angular2.d.ts)。我們還從nuget(https://www.nuget.org/packages/angular2.TypeScript.DefinitelyTyped/)安裝了它,並獲得了相同的空文件 - 可能它跟不上角度發展?
Error TS1148 Cannot compile modules unless the '--module' flag is provided. Angular2TS_Test c:\Users\Ophir_O\documents\visual studio 2015\Projects\Angular2TS_Test\Angular2TS_Test\app\app.ts 3 Active
Error TS2307 Cannot find module 'angular2/core'. Angular2TS_Test c:\Users\Ophir_O\documents\visual studio 2015\Projects\Angular2TS_Test\Angular2TS_Test\app\app.ts 3 Active
Error Build: Argument of type '{ selector: string; templateUrl: string; }' is not assignable to parameter of type '{ selector: string; properties?: Object; hostListeners?: Object; injectables?: List<any>; lifecyc...'. Angular2TS_Test c:\users\ophir_o\documents\visual studio 2015\Projects\Angular2TS_Test\Angular2TS_Test\app\app.ts 9
Error Build: Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning. Angular2TS_Test c:\users\ophir_o\documents\visual studio 2015\Projects\Angular2TS_Test\Angular2TS_Test\app\app.ts 12
Error TS1219 Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning. Angular2TS_Test c:\Users\Ophir_O\documents\visual studio 2015\Projects\Angular2TS_Test\Angular2TS_Test\app\app.ts 12 Active
什麼是正確的方式來啓動與TypeScript和VisualStudio的angular2項目?我們找不到任何最新的指南...
謝謝。那麼空的'd.ts'文件怎麼樣? – developer82
此項目類型不支持'A'tsconfig.json'文件 – developer82
關於空白d.ts:Angular2在npm包中有所有類型。在「空白」文件中看到這一行。 https://github.com/DefinitelyTyped/DefinitelyTyped/blob/cdd23d1/angular2/angular2.d.ts#L6 – Wilgert