AngularJs 2与ASP .NET 4.5.1

我想使用Angular 2作为现有的ASP.NET 4应用程序的前端,即不是MVC 6 / ASP.NET CORE,我宁愿不使用节点,因为我们已经使用nuget作为我们的包pipe理器。 有谁知道任何资源,将指导我通过这个?

为了回答我最初的问题,这就是我们如何设法使用.net 4.5.1来运行Angular 2(我们最终不得不使用npm)。

在_Layout.cshtml的头文件中,从cdn和configuration好的SystemJs中导入Angular 2文件。

<!-- 1. Load libraries --> <!-- IE required polyfills, in this exact order --> <script src="../../node_modules/es6-shim/es6-shim.min.js"></script> <script src="../../node_modules/systemjs/dist/system-polyfills.js"></script> <script src="../../node_modules/angular2/es6/dev/src/testing/shims_for_IE.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> <!-- 2. Configure SystemJS --> <script> System.config({ packages: { 'my-app': { format: 'register', defaultExtension: 'js' } } }); System.import('my-app/main') .then(null, console.error.bind(console)); </script> 

将package.json和tsconfig.json添加到项目的路由中

packages.json:

 { "name": "angular2-quickstart", "version": "1.0.0", "scripts": { "tsc": "tsc", "tsc:w": "tsc -w", "typings": "typings", "postinstall": "typings install" }, "license": "ISC", "dependencies": { "angular2": "2.0.0-beta.9", "systemjs": "0.19.24", "es6-promise": "^3.0.2", "es6-shim": "^0.35.0", "reflect-metadata": "0.1.2", "rxjs": "5.0.0-beta.2", "zone.js": "0.5.15" }, "devDependencies": { "typescript": "^1.8.7", "typings": "^0.7.5" } } 

tsconfig.json:

 { "compileOnSave": true, "compilerOptions": { "target": "es5", "module": "system", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false }, "exclude": [ "node_modules", "typings/main", "typings/main.d.ts" ] } 

如果你的机器上安装了node和npm,它应该自动下载你需要的npm模块,并将它们保存在node_modules文件夹中。 您现在应该准备好设置一个Angular 2应用程序,我们使用这个来开始。

他们已经用非核心场景更新了Angular网站:

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

我跟着https://angular.io/docs/ts/latest/cookbook/visual-studio-2015.html ,遇到了一个问题,这只是为了帮助,如果有人跑到相同的。

出于某种原因,我没有得到一个新的项目package.json恢复软件包选项,重新启动视觉工作室2015年专业带来了select。

而我不得不复制systemjs.config.js在项目文件夹中,否则它被卡在加载…,开发人员栏显示404为systemjs.config.js和复制它带来了“我的第一个angular度的帮助”。