Daniel Bastos
Daniel Bastos

Reputation: 150

How to use ASPNET MVC with Angular 2?

I'm new around Angular, but I decided it was a good thing to learn in my spare time.

I've been looking around the web and most of the things I found was using Angular 2 with ASPNET Core.

I have an application I made for school this semester, in ASPNET MVC with entity framework, that has some CRUD and A&A. Is it possible to integrate Angular 2 in this application and if so how would I do it? I would especially like to be able to still use my login and register controllers if possible!

If anyone could send a good tutorial or something that would help I'de be very grateful!

Upvotes: 0

Views: 1085

Answers (2)

Daniel Bastos
Daniel Bastos

Reputation: 150

I'm answering my own question beacause after some digging up I came across this this where the writer explains, step-by-step what to do, to integrate Angular2 to a pre existent AspNet MVC web app that you have.

Still I want to give a thanks to Pankaj Kapare, his answer was the only obvious next step for me, and also to brando that in a comment suggested this as answer and it was almost identically to Pankaj's answer.

Upvotes: 1

Pankaj Kapare
Pankaj Kapare

Reputation: 7812

Typically people use Angular for developing UI layer of application and ASP.Net Web APIs for services. If I were you I would follow below approach.

  1. Start with installing ASP.Net Core template pack extension which has ASP.NET Core + Angular 2 template.
  2. Convert existing CRUD operation to Web APIs. If you existing code is modular enough then you can reuse it as is just by writing Web API wrappers around those CRUD operations.
  3. Once APIs are ready to be consumed by UI (which will be implemented in Angular 2) then start writing your presentation and data rendering logic using Angular 2. You would call web apis to push/pull data to your angular views.
  4. There are many tutorials out there on this very topic. Pick any one of them to make yourself comfortable to understand flow, how to consume web apis etc. and you should be good.

Hope that helps.

Upvotes: 2

Related Questions