4 angular 重构 项目,将Angular 4添加到ASP.NETCore项目

I want to utilize Angular 4 in my ASP.NetCore 1.1 project, within Visual Studio 2017 (read as: *.csproj file)

Previously with ASP.NET Core 1.0 and Visual Studio 2015, you could simply add AngularJS (1.x.x) into the project.json as a dependency and it would wire itself in.

Now, with ASP.NetCore and VS2017, the project.json file has gone away, and the only documentation I can find refers to STARTING an Angular 4 project by using the CLI and using the CLI to generate a NEW angular app. I don't really want a new project or have to refactor everything I have created to provide a service to a separate UI project. I just want to augment my app with some added client-side UI experience.

Any suggestions?

Update

This questions has been getting a lot of views and the information is of little help so I'm providing this update.

Visual Studio 2017 (*.csproj)

Asp.Net Core 2.0 + Angular (v2.0~v4.0) :: Use the built in template! Best option IMO.

Asp.Net Core 1.X + Angular (v2.0~v4.0)

Create VS Project.

Create Angular Project via Angular CLI

Configuration and setup details : Link

Visual Studio 2015 (project.json)

Tooling: up to version -preview2 - No further updates, all new .NET Core features will be moving to VS 2017

Asp.Net Core 1.X + Angular (v2.0~v4.0)

Asp.Net Core Template Pack

Note: I wouldn't endorse a bad VS Plugin, Mads Kristensen does good work.

Configuration and setup details : Blog post

Asp.Net Core 1.X + AngularJS (~1.5)

Configuration and setup details : Microsoft Tutorial

Asp.Net MVC 5 + AngularJS (~1.5)

Notes: There are many other ways to get Angular to work with ASP.Net / .NetCore projects such as NPM, Bower, NuGet, etc. I tried to highlight the ones which are simple and actually work. Also these are in line with the direction Microsoft is moving in, according to the Pluralsight blog post above.

解决方案

[i am aware you didn't ask this specifically but just wanted to share a thought which is very relevant in my opinion]

I was at the exactly the same point a few months ago and i decided going with angular cli. and i thank God i made that decision.

Uncomparably more clear and it actually put things how they should be: .net core web api backend and completely separated angular client. just exactly the same as you wouldn't put your iphone/android app into VS solution, there is no real reason to put angular one neither.

UPDATE

Either use MVC with Razor, OR use Angular as a SPA, and if you use Angular, use the Angular CLI.

And if you use angular, feed data into it with asp.net (core) Web Api as a REST backend

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值