Last active
December 30, 2015 05:58
-
-
Save davidbanham/7785700 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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