Angular.js and ASP.NET MVC 4 [closed] Angular.js and ASP.NET MVC 4 [closed] javascript javascript

Angular.js and ASP.NET MVC 4 [closed]


my 2 cents worth.

preamble - i have worked with both angular and knockout.I'm on my 3rd non trivial front end built with a MVVM/MVC lib.

I started with knockout because its MVVM is very similar to the wpf/silverlight mechanics. And it works well. The tutorials and documentation are top notch. All your coders will be able to work with knockout.js within days or if they have used mvvm under .net, then within hours.

However, these days I am using angular and will probably stick with it for the following reasons.

  • angular is a complete framework - knockout is really about just the 2way binding. you still need other libraries like backbone.js/jqueryto do the rest of your work.

  • angular has dependency injection. which is perfect for adding
    mocking for testing as well as giving structure to your code.

  • angular treats normal JS variables as observables within its $scopeobject. that means you dont have to declare them in a special way

I'm not an angular fanboy, i still think they could move more over to the MVVM architecture instead of the "funky" MVVM/MVC hybrid architecture they currently have.

The biggest problem with angular is the documentation. Compared to knockout, it is woeful. It will add additional time and cost to getting your coders up to speed. Once they are there however, it is currently the best choice IMHO.


Glad to see this questions was of interest to the community ;) Just for completeness here's what I ended up doing:

I did go with AngularJS and ASP.NET MVC 4 and was glad that I did. Although, Angular has a steep learning curve but its worth it because of the power of directives.

  • We need two-way model data binding - On occassion I needed to set some initial values coming from the MVC controller. I used the ng-init attribute to accomplish this.
  • We need the ability to test views - I followed the AngularJS docs for testing
  • "Save Changes" functionality - I implemented this using a directive in Angular
  • "Notifications" functionality - I implemented this using toastr.js and and directives (schweet)
  • We need to "future proof" our application - I don't know Google's plans for AngularJS, but after working with AngularJS I can't see it going anywhere anytime soon and expected it to become more widely adopted :)


I don't have a lot of input on AngularJs, but want to provide some thoughts on Knockout.

Knockout is primarily a data-binding library to connect views to view model, but doesn't really provide a lot of capabilities beyond that. I wouldn't recommend using knockout alone as the main library to build a complex client-based web site.

You didn't mention whether you're implementing spa-like functionality (i.e. hash-tag navigation) or whether you're primarily using MVC server-side views (e.g. Razor). If you're just looking for quick data-binding on a per-page level, I would even reconsider that. To me, both of these (angular or knockout) are designed to enhance the client-side development experience - not so much a server-side approach such as MVC.

If you're considering an SPA approach, even in part, you'll likely want some framework that provides some level of control over the view activation life cycle.

As far as data-binding power and reliability, I believe in Knockout. I have been using it extensively, and have grown quite fond of it. If you like the feel of knockout, you may want to look into Durandal. Durandal is a decent framework is able to meet the needs of many "spa" web projects. It's a client-side framework built on top of several proven libraries, including Knockout. It's a little (lot) more light-weight than Angular, and possibly easier to user.

We are building a fairly large ASP.Net MVC web site using Durandal with Knockout in conjunction with an additional facade to tighten things up from a development standpoint, and the integration with ASP.Net MVC is straight-forward. I don't recommend trying to use the server-side knockout stuff that's out there; I just find that to limit the real power of the MVVM pattern.