0

I have an existing web app that is built upon an mvc architecture. Can I add ng2 components to an html view rendered in mvc? Let's say my mvc app has a UserView, UserModel, UserController. How would I go about adding an ng2 component to UserView?

I have the angular.io tour of heroes final app running on my laptop. The main page is index.html and all ng2 app files exist in an "app" folder. Is it possible to create some type of partial view that I can render on my mvc UserView? If so then how would I go about doing this?

pzaenger
  • 11,381
  • 3
  • 45
  • 46
  • Are you attempting to only incorporate *some* of Angular2 into your app? I'm not certain that this is generally possible unless you're either porting over from Angular 1, or without lots of pulling of teeth. – Makoto Nov 06 '16 at 19:59
  • I have an mvc app and I'm trying to incorporate ng2 components. For example, let's say I have an existing mvc app that displays a product details page and I want to display an ng2 widget on the page with like/share urls to various social media sites. Is this possible? Seems like a reasonable use case for a js framework to support. Someone on my team mentioned to me that this was possible with ng1 – user7117607 Nov 06 '16 at 20:13
  • I found a few urls regarding this approach: * http://stackoverflow.com/questions/31463911/angular2-component-without-view-annotation * http://stackoverflow.com/questions/36840967/how-to-pass-data-from-asp-net-mvc-to-angular2 Looks like it's possible and people are doing it. Not sure what the best approach for this is especially now that ng2 is 2.1 – user7117607 Nov 06 '16 at 20:17
  • You can do it - but I would ask if it really makes sense ? For example routing would be a nightmare. Secondly you would find that you would move more and more to either mvc or angular. Better to use a simple data binding network if that's what you are after. – Piotr Stulinski Nov 06 '16 at 21:15

0 Answers0