Skip to content

Instantly share code, notes, and snippets.

@davidbanham
Last active December 30, 2015 05:58
Show Gist options
  • Save davidbanham/7785700 to your computer and use it in GitHub Desktop.
Save davidbanham/7785700 to your computer and use it in GitHub Desktop.
#Sometimes I want to munge data that I've pulled from a backend with Angular. The Promises implementation augments the object with it's own $properties and I don't want to munge those.
app = angular.module 'GetOffMyLawn'
app.controller 'DangKids', ($scope, $resource) ->
Wat = $resource '/wat'
Wat.get {}, (data) ->
#data is something like { foo: {something: 1, somethingElse: 2} }
for k, v of data
#But we need to check for the $properties added by the Promises implementation.
if k.charAt 0 is '$'
console.log 'Get off my lawn!'
continue
#If that's fine, then munge the data
v.computedValue = v.something * v.somethingElse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment