use $resource. pretty sweet.