Have an MVC app with razor pages. Converting it to use Knockout. Then once complete, will go back and convert all Knockout to Angular. I want to get educated on that strategy. Not a pros and cons question; I mean logically it is inefficient as the rewrite might be more difficult than if we were to go straight to Angular. What pitfalls, gotchas, or lessons learned have other people had converting Knockout to Angular?
1 Answers
I've done both knockout and angular development. It's easier to go from knockout to angular than the other way around. Obviously the least amount of work would be in going straight to the framework/library you intend to end with.
Knockout is easier to replace razor with because it's just a simple binding library, so you can stick with razors routing and replace the razor syntax with knockout js files and html. That is, unless you want to pair knockout with require.js so you can serve up a single html page from your MVC app and treat it as a single page application. That is possible as well.
If you're going full SPA, go straight to Angular and pair it with ASP.Net Web API 2. Serve up a single page and then make all subsequent requests return json. You can do that with MVC too but Web API 2 is better.
You could also keep the server side routing of MVC and serve up single small apps at a time of Angular, but that's pretty meh.
Best option? Angular SPA served once on the root of the app, all routing handled in angular using ui-router (2 is out i think), and then back it on the server side by ASP.Net Web API 2.

- 2,650
- 2
- 14
- 23