I'm making a CRUD page using AngularJS, which will have an add/edit/delete function. So, my routes will be something like this:
/items (show a list of the items)
/items/add (show add item form)
/items/edit/:itemId (show edit item form)
/items/del/:itemId (Delete item)
It seems that I would have to define a different controller for each of these 4 routes. E.g, AddItemCtrl, EditItemCtrl, etc. However, that doesn't seem optimal since the AddItemCtrl and EditItemCtrl are going to share a good deal of their code. Rather than AddItemCtrl, EditItemCtrl, etc, I would rather have only one controller: ItemCtrl , and within my route, I'd rather specify if I want to call ItemCtrl.add(), ItemCtrl.edit(), etc.
Is there a way to accomplish this or something close to it?
 
     
    