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

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

问题描述

我正在尝试将通过CLI项目生成的Angular 5应用程序集成到现有的ASP.NET MVC 5应用程序中.我在ASP.NET MVC项目中使用CLI创建了angular项目,并且我想在剃刀视图中使用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-安装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/zh-cn/aspnet/core/spa/angular?tabs = visual-studio#tabpanel_IjUmMTId-R_visual-studio

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

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