Reputation: 167
What is the best way to use multiple modules of Angular 4 within Asp.Net Core MVC context ?
I have an app that has couple of sections, each represented by a controller and a view. On those sections, I'd like to use Angular to implement sub-sections (so let's say - for ShopController/View, I would like to have subpages - Shop/Items Shop/Cart Shop/Details etc.).
It's a no brainer with one section, as for example - for Shop I can put <app-root>
in shop's Index view, where app-root is an AppComponent with <router-outlet>
, residing in main AppModule (along with it's routing), but what if I have multiple such cases - so Shop section (ShopController), then Setting section (SettingsController) etc. where each section should have their own sub-routing controlled by Angular ?
Upvotes: 0
Views: 553
Reputation: 4451
You should not create separate views on the server to correspond to sub-components of your Angular ShopComponent. One of the main purposes of using Angular is to be able to create a "single page application", where you would only return to the server for data required by the application.
You could use Angular "Child Routes" to define the the Shop/Cart and Shop/Details routes. See: https://angular-2-training-book.rangle.io/handout/routing/child_routes.html
Upvotes: 1
Reputation: 548
In Angular js 4 and Asp.Net application difficult to handle routing, either you need to choose asp.net routing or angular js routing. Because it two routing handling in separate section Asp.net in Register router routing table in Angular angular routing outlet.
if you using both you definitely get routing error in page refresh
So as of now no connected routing system not implemented and not available in Asp.net Core and Angular 4 routing.
Upvotes: 0