Server side C# MVC with AngularJS

Posted by Ryan Langton on Programmers See other posts from Programmers or by Ryan Langton
Published on 2014-03-21T19:49:49Z Indexed on 2014/06/01 15:53 UTC
Read the original article Hit count: 389

Filed under:
|
|

I like using .NET MVC and have used it quite a bit in the past. I have also built SPA's using AngularJS with no page loads other than the initial one. I think I want to use a blend of the two in many cases. Set up the application initially using .NET MVC and set up routing server side. Then set up each page as a mini-SPA. These pages can be quite complex with a lot of client side functionality.

My confusion comes in how to handle the model-view binding using both .NET MVC and the AngularJS scope. Do I avoid the use of razor Html helpers? The Html helpers create the markup behind the scene so it could get messy trying to add angularjs tags using the helpers. So how to add ng-model for example to @Html.TextBoxFor(x => x.Name). Also ng-repeat wouldn't work because I'm not loading my model into the scope, right? I'd still want to use a c# foreach loop?

Where do I draw the lines of separation? Has anyone gotten .NET MVC and AngularJS to play nicely together and what are your architectural suggestions to do so?

© Programmers or respective owner

Related posts about asp.net-mvc

Related posts about angularjs