asp.net – AngularJs 2与ASP.NET 4.5.1
发布时间:2020-05-24 01:36:08 所属栏目:asp.Net 来源:互联网
导读:我想使用Angular 2作为现有ASP.NET 4应用程序的前端,即不是MVC 6 / ASP.NET CORE,我宁愿不使用节点,因为我们已经使用nuget作为包管理器.有人知道有什么资源可以指导我吗? 为了回答我的原始问题,这是我们如何设法使用.net 4.5.1(我们最终不得不使用npm)使Angu
|
我想使用Angular 2作为现有ASP.NET 4应用程序的前端,即不是MVC 6 / ASP.NET CORE,我宁愿不使用节点,因为我们已经使用nuget作为包管理器.有人知道有什么资源可以指导我吗? 解决方法为了回答我的原始问题,这是我们如何设法使用.net 4.5.1(我们最终不得不使用npm)使Angular 2运行.在_Layout.cshtml的标题中,从cdn和已配置的SystemJ导入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"
]
}
如果您的机器上安装了节点和npm,则应自动下载所需的npm模块,并将其保存在node_modules文件夹中.您现在应该准备好设置一个Angular 2应用程序,我们使用this开始使用. (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Razor页面在运行时无法在ASP.NET Core RC2中看到引用的类库
- asp.net-membership – Asp.net会员 – 帐户被锁定
- asp.net-mvc – MVC Razor HTML助手语法:Viewbag in Html.
- asp.net-mvc – 为什么我们使用ViewModels?
- Asp.net mvc – Html提交按钮未发送帖子?
- asp.net-mvc-4 – 如何通过MVC4 upshot上传相关实体
- asp.net-mvc – ASP.NET MVC3 – 3层设计 – 事务控制和业务
- asp.net – Glass Mapper打破了图像字段的标准值
- asp.net-mvc-4 – 使用基本HTTP身份验证的MVC4 app WebApi中
- asp.net – 表单身份验证是否与Web负载平衡器一起使用?
