angularjs - AngularFire equivalent to $setPristine? -
i'm trying understand correct workflow create $setpristine equivalent firebase data.
my workflow follows:
1) create firebase object (via angularfire generator 'syncdata')
2) form data modifies $firebase object.
3) update remote model, use myref.$save()
all of works well. now, i'm trying add "reset" button on form, locally modified data revert remotely stored data.
so far, i'm running problems. i've tried reinitializing firebase reference eg myref = syncdata('/my/path')
not work, destroying remote data object!
what correct way re-pull remote data use in angular model?
i know old question, ran issue myself.
after searching around found post: http://grokbase.com/t/gg/firebase-angular/1499haaq4j/editing-data-as-a-copy
which led me outdated code snippet (2 months lol xd) @kato: https://gist.github.com/katowulf/8eaa39eab05a4d975cd9
i modified work firebase 2.3.1 , angularfire 1.1.3:
app.factory('resetfactory', function($firebasearray) { return $firebasearray.$extend({ reset: function(itemorindex) { var key, self; self = this; key = self.$keyat(itemorindex); self.$ref().child(key).once('value', function(snap) { self.$$updated(snap); }); } }); });
which can called via:
var comments = new revertfactory(ref.child('comments')); # variable comment example ng-repeat that's being edited comments.reset(comment);
Comments
Post a Comment