将 Angular 5 与 ASP.NET MVC 5 集成 [英] Integrate Angular 5 with ASP.NET MVC 5

查看:17
本文介绍了将 Angular 5 与 ASP.NET MVC 5 集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将使用 CLI 项目生成的 Angular 5 应用程序集成到现有的 ASP.NET MVC 5 应用程序中.我在 ASP.NET MVC 项目中使用 CLI 创建了 angular 项目,我想在 razor 视图中使用 Angular 5 组件;这些将是简单的剃刀视图,在这些视图中,我将显示一些 Angular 5 组件.我已经用 ASP.NET Core 2 做到了这一点,我将 .angular-cli.json 文件中的 Outdir 属性更改为 wwwroot,它有效,但我无法使用 ASP.NET MVC 5 做到这一点.任何人都可以帮忙吗?谢谢

I am trying to integrate an Angular 5 app generated with CLI project into an existing ASP.NET MVC 5 application. I created the angular project with CLI inside the ASP.NET MVC project, and I want to use Angular 5 components inside razor views; those will be simple razor views and inside those, I will display some Angular 5 components. I've done this with ASP.NET Core 2, I changed the Outdir property to wwwroot in the file .angular-cli.json, and it worked, but I could not do it with ASP.NET MVC 5. Can anyone help? Thank you

PS:许多教程使用旧版本的 Angular,他们使用名为 system.js 的文件,但该文件在较新版本的 Angular 中不再存在.

PS: many tutorials use old versions of Angular and they used a file named system.js, but this file does not exist anymore in the newer versions of Angular.

推荐答案

您是否看到了新的 Microsoft Core Angular 模板的候选发布版本.他们更改了模板,使其使用 angular-cli.效果很好.您可以遵循相同的构建配置模式.请注意,您必须通过

Have you seen the release candidate for the new Microsoft Core Angular template. They changed the template so that it uses angular-cli. Works well. You could possibly follow the same build config pattern. Note you have to install the newest version of the template via

dotnet new --install Microsoft.DotNet.Web.Spa.ProjectTemplates::2.0.0-rc1-final.

dotnet new --install Microsoft.DotNet.Web.Spa.ProjectTemplates::2.0.0-rc1-final.

https://docs.microsoft.com/en-us/aspnet/core/spa/angular?tabs=visual-studio#tabpanel_IjUmMTId-R_visual-studio

这篇关于将 Angular 5 与 ASP.NET MVC 5 集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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