Cancelling / reverting changes to models in angular.

Right up front I’m going to say that i haven’t found the right answer to this problem. Yet.

outline

Add undo or save abilities to edits on a model in Angular.

I have two templates which bind to my model. The edit template and the view template. When in the view the data is bound essentially one way and there is no problem. For edit, angular has some great binding that reacts to change events and sets the model value to the current value of the input. This is a key aspect of the angular frame work, and in a lot of places, this data-binding is really useful, except if you not sure you want to keep those changes.

the two way binding will overwrite the original model with the new changes and then the original values are gone. so how do i implement a cancel/revet button?

things i have tried already

‘get’ the model again from a saved point. This involves making a request to the server for the original model value. Its expensive both in network & time, so doesn’t lead to a great user experience. Also this breaks for things not yet stored on the server.

copy & change. Take a copy of the model, edit that and push the changes back on save. The failure here is that with an async system like javascript, my model might not be fully loaded at the point i want to copy, and even if it is, how do i reflect changes to the original in my ‘editing’ copy?

cacheing the model on each ‘save’ which allows me to get the original value back if my edit are cancelled. Still changes to the original from another source need to be re-cached.

 

so im ata a loss. for now. ill write back if i find a suitable answer.

 

Advertisements

Developing for the Cloud in the Cloud

For a while now ive been messing about with Cloud9, an online IDE primarily aimed at node.js, or ruby developers. First off, i love it.

I cant speak to Node.JS or Ruby development in Cloud9, but for what ive been doing its worked great. So what have i been doing? Well ive been working on a small side project for my dive club ‘QuoteBook’ This web app is going to allow the members to add in quotes from people in the club and then read them later.

The specs of the project are rather simple but the execution is where im starting to take advantage of all the amazing SaaS and Open Source resources avaliable to developers these days.

Rundown as it stands so far (im only about 50% of the way through my project):

The application will be client side JavaScript/HMTL/CSS based with a good starting point of bootstrap, using parse for all my backend persistent stuff and jQuery, with thanks to steven for his jQuery-Parse module, to link these together. All of which will obviously be kept in a GitHub Repo of my own. 

Cloud9 has GitHub integration which meant including jQuery, bootstrap, and the parse module into my project was a matter of a few ‘git pull’ commands. C9 has made my ‘casual development’ approach to creating a web app so easy that even when i try out other approaches such as full blown IDE for all the bells and whistles i.e. aptana IDE or lightweight with just Notepad++ i keep coming back to C9. Always avaliable, just the right amount of bells and more than capable for the small projects im likely to attack in the future, i would recomend this approach to anyone.