Reputation: 4672
I have stripped my problem down to the most minimal form, as seen here: http://jsfiddle.net/ejubN/
I basically want to be able to load a large JSON object into $scope.b that gets rendered. And if any of the elements in @scope.b are changed, updated, or if a new one is created, then 'contenteditable' should be triggered to save that back to my rails application via a POST.
Upvotes: 2
Views: 1302
Reputation: 37785
This fiddle shows some code that will call a listener whenever $scope.b
changes: http://jsfiddle.net/Gloopy/SQuVy/
I may have stripped the example down too far but I'm assuming you don't need a directive and you were basing this off a sample from the AngularJS docs. Also I changed $scope.b
to contain javascript objects instead of primatives due to binding issues with ng-repeat described here (which will hopefully be a better test since you're loading a large JSON object).
You should be able to do your post using the $http service though posting every time the listener fires is probably not ideal. Others may have better suggestions on when to actually do your saves but hopefully this helps!
Upvotes: 2