Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Thinking about this a little more. You could just have a single controller for those generic CRUD/REST type operations. Then load the templates using the resource and view parameters. </p> <ul> <li>Create <ul> <li>#/foo/create/0</li> <li>This has it's own form template "/views/foo/create.html" and the 0 os just there for a placeholder. </li> <li>on submit you would call a method on the controller ng-click="save()" which would post to the server at POST "/rest/foo".</li> </ul></li> <li>Read <ul> <li>#/foo/view/1</li> <li>Again the template "/views/foo/view.html" is just a view of the data</li> <li>You can call a service method to get the data from your server using GET "/rest/foo/1"</li> </ul></li> <li>Update -#/foo/edit/1 <ul> <li>Could use the same template as create or you could use a different one "/views/foo/edit.html" if you like.</li> <li>Also pull the data using GET "/rest/foo/1"</li> <li>Submit the data using PUT "/rest/foo/1"</li> </ul></li> <li>Delete <ul> <li>#/foo/delete/1</li> <li>service method would call DELETE "/rest/foo/1"</li> <li>I don't think you want a hash for this, but you could use one because the controller could actually do a verification or anything you like to confirm the deletion. Maybe have a view called "/views/foo/delete.html" that asks if you want to delete the record. Then you could have ng-click="delete(itemid)" on a button somewhere that deletes the item via ajax.</li> </ul></li> </ul> <p>All this could be done using a single controller/service and dynamically generating the service and view urls.</p> <p>Anything that's custom you would need a custom controller and custom routes and service methods for. I could probably throw together an example, but not tonight. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload