We were using ASP.NET Razor, and we heavily used Razor to generate HTML, include partial views in layouts, and stuff like that.
However, now that Angular is out and robust, we want to use it as much as we can.
A fellow colleague suggested that theoretically it should be possible to completely replace Razor with Angular JS, and we researched it, and it seems viable.
For example, we can replace Html.Partial
with ngInclude
, we can replace RenderBody()
with <ng-view>
, we can replace loops with ng-repeat
, etc.
Is there any pitfall for putting Razor aside and working only with Angular? Did we miss something?
I am not even sure you have an issue here. Both engines do the same thing essentially, the difference being that Angular JS happens on the client and Razor happens on the server. By all means, shift the dynamic parts to the client if the rendering and logic does not require the server to do so.
If I were you I'd still use Razor files to generate the final html. You might find it useful in the future for those times when something must be generated on the server. Perhaps you could end up serving an entirely different control based on user-permissions. This is important because if security-sensitive rendering is occurring on the client, it can potentially be circumvented by someone. However if that code never arrives because the server generated it, you're in a better place.