Open Closed

Lame question on angular #1095

easyest created

Currently every edit form in ASP.NET Zero is shown in a modal using $uibModal and is only one controller. Following this sample is really easy. But what if I would like to show "edit" form that would have two controllers and their views? For example 1 controller is a controller for shop entities and shows shop list. Second controller is a controller for item prices in that shop and shows item price list. This second controller is reused elsewhere, so should be separated from shop controller. My questions would be: How should I open view with multiple controllers and their views? How should I pass ID of the shop, that is selected in the first controller for the second controller to show correct price list?

And another situation - there is a list of shops, when clicked on an entry in this list another page with shop's edit form and a list of it's prices should be shown. How many controllers should there be and how navigation should be done, if price list and editing code is intended to be reused elsewhere?

1 Answer(s)
  • 0
    hikalkan created
    Support Team


    Your question is related to Angularjs, since $uibModal is an angular service. I suppose, you can set only one controller for a modal. But, you can include two views (and their controllers) in your modal. Or you can create a reusable directive with it's own controller and use it in a modal. We did a similar think for role edit modal for example. We use permission-tree directive to show permission tree in the second tab. You can share models between controllers. We also did it for permission tree. Maybe you can use abp's client side events to inform another controller from a different controller.

    For 2nd case, if you will not use modal, you can create 2 separated views, add routes and transfer to second view when you click an item in first view. We did similar thing for language management. When you click 'edit texts' menu item for a language, you go to another view to edit the clicked language's texts. I think your case is similar.