Aaron,
I implemented something like this recently; unfortunately this was for an internal app so I can post the code here, but I can help you walk through the issues involved.
Basically, I wrote a generic modal directive with a generic controller providing a scope for the model to be modified in the modal and open, confirm, dismiss and lock functionality (the latter is really important as well!).
Then, I wrote directives for each modal/resource type, e.g., a video-modal, document-modal etc. These directives all require the generic modal's controller and I can use it to easily open modals for given resources from all over the application without having to worry about the scope-tree and so on.
New objects are passed into the modal as is, otherwise I save a reference to the original object and send a duplicate to the modal – like you said, this is necessary so that canceled changes are never propagated to the model on the page.
When the modal is dismissed all references can simply be discarded; when you save, however, the modal is locked so that it can't be accidentally closed while the object is being saved. If saving fails, the modal is unlocked and you can display appropriate error messages; if the object was saved successfully, you can add it to the page (if it was a new object) or replace the original object with the updated one.
hth,
Sylvester
> --
> You received this message because you are subscribed to the Google Groups "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
angular+u...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>