如何使用 TypeScript 使 angular2 在 Visual Studio 2015 中工作? [英] How can I get angular2 to work in Visual Studio 2015 with TypeScript?

查看:27
本文介绍了如何使用 TypeScript 使 angular2 在 Visual Studio 2015 中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让 Angular 2 在带有 TypescriptVisual Studio 2015 中工作.我试图让最基本的例子在 MVC 5 类型的 web 项目中工作(web.config 而不是 config.json):

I am trying to get Angular 2 to work in Visual Studio 2015 with Typescript. I am trying to get the most basic example to work in an MVC 5 type web project (web.config instead of config.json):

import {Component, bootstrap} from 'angular2/angular2';

@Component({
    selector: 'my-app',
    template: '<h1>My First Angular 2 App</h1>'
})
class AppComponent { }
bootstrap(AppComponent);

我正在尝试完成这项工作所需的最少的东西.所以我下载了最新的 Angular 2 (alpha .45) 并复制了下载的 modules 文件夹中的所有 TypeScript.包括所有子文件夹(减去docsexamples 的.)

I'm trying the most minimal things needed to make this work. So I downloaded the most recent Angular 2 (alpha .45) and copied over all of the TypeScript in the downloaded modules folder. Including all of the subfolders (minus the docs and examples ones.)

我确信这将在 Visual Studio 之外工作,因为我以前做过这个,但我试图让它在 Visual Studio 中工作,它是给了我 3,000 多个错误,看起来是因为我缺少其他模块或其他东西.

I am sure that this will work outside of Visual Studio as I have done this before, but I am trying to get it to work in Visual Studio and it is giving me over 3,000 errors and it looks like it is because I am missing other modules or something.

这里有一些我缺少的东西:

Here are a couple of the things I am missing:

地图(default_keyvalue_differ.ts 和许多其他):

export class DefaultKeyValueDiffer implements KeyValueDiffer {
  private _records: Map<any, any> = new Map();

断言(lexer.ts):

  scanCharacter(start: number, code: number): Token {
    assert(this.peek == code);

设置(command_compiler.ts):

Set (command_compiler.ts):

function removeKeyValueArrayDuplicates(keyValueArray: string[]): string[] {
  var knownPairs = new Set();

startsWith (shadow_css.ts)

startsWith (shadow_css.ts)

rule.selector.startsWith('@page')

需要 (parse5_adapter.ts)

require (parse5_adapter.ts)

var parse5 = require('parse5/index');

@reactivex/rxjs/dist/cjs/Rx (async.ts)

@reactivex/rxjs/dist/cjs/Rx (async.ts)

export {Subject} from '@reactivex/rxjs/dist/cjs/Rx';

还有很多.所以我的第一个问题是,我真的需要所有这些东西,还是不需要其中的一些.第二,更重要的是,我如何让 Visual Studio 构建我的解决方案?

There is much more than this. So my 1st question is, do I really need all of this stuff, or is some of it not required. 2nd and more importantly, how do I get Visual Studio to build my solution?

注意:我认为这个非常长的示例/教程"是我一直在寻找的,除了它适用于 MVC 6 (.NET Core) 而不是 MVC 5:http://chsakell.com/2016/01/01/cross-platform-single-page-applications-with-asp-net-5-angular-2-typescript/

Note: I think this "very long example/tutorial" is what I was looking for except it's geared for MVC 6 (.NET Core) instead of MVC 5: http://chsakell.com/2016/01/01/cross-platform-single-page-applications-with-asp-net-5-angular-2-typescript/

推荐答案

我知道 SO 并不热衷于粘贴指向内容的链接,但这是一个相当大的教程要遵循,只需将粘贴复制到此处...它的所有部分都与回答问题有关.无论如何,这里是 Angular 2 团队提供的教程,用于让 NG2 在 Visual Studio MVC 5 中工作:

I know that SO isn't keen on pasting links to stuff, but this is a fairly large tutorial to follow, to just copy paste into here... and all bits of it are relevant to answer the question. Anyways, here's the tutorial provided by the Angular 2 team to get NG2 working in Visual Studio MVC 5:

https://angular.io/docs/ts/latest/cookbook/visual-studio-2015.html

这篇关于如何使用 TypeScript 使 angular2 在 Visual Studio 2015 中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆