o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1374161914.245701: @value"1{I" class:EFI"ProcessedAsset;FI"logical_path;FI"Bcollection_json_browser/angular/controllers/api_controller.js;TI" pathname;FI"ƒ/Users/weilu/workspace/collection-json-browser/app/assets/javascripts/collection_json_browser/angular/controllers/api_controller.js;TI"content_type;FI"application/javascript;FI" mtime;FI"2013-07-18T23:37:46+08:00;FI" length;FiOI" digest;F"%eb68a8995751f641b3f082f75b969acfI" source;FI"O'use strict'; function ApiController($scope, $http, $location) { $scope.goTo = function(path, fromRel) { $scope.fromRel = fromRel $location.path(path) } $scope.submit = function() { $scope.fromRel === 'edit-form' ? put() : post() } $scope.$watch(function() { return $location.path() }, function(path, oldPath) { if(path !== oldPath) get(path) }); get('/api') // helpers function get(path) { $http.get(path).success(successHandler) } function post() { $http.post($scope.collection.href, formData()).success(successHandler) } function put() { $http.put($scope.collection.href, formData()).success(successHandler) } function formData() { var data = {}; $scope.collection.template.data.forEach(function(f){ data[f.name] = f.value }) return data } function successHandler(data, status) { $scope.collection = data.collection; $scope.raw = JSON.stringify(data, undefined, 2) $scope.status = status $location.path($scope.collection.href) } } ApiController.$inject = ['$scope', '$http', '$location']; ;FI"dependency_digest;F"%b949e9af421592eebb9dc66f4697ba58I"required_paths;F[I"ƒ/Users/weilu/workspace/collection-json-browser/app/assets/javascripts/collection_json_browser/angular/controllers/api_controller.js;TI"dependency_paths;F[{I" path;FI"ƒ/Users/weilu/workspace/collection-json-browser/app/assets/javascripts/collection_json_browser/angular/controllers/api_controller.js;TI" mtime;FI"2013-07-18T23:37:46+08:00;FI" digest;F"%eb68a8995751f641b3f082f75b969acfI" _version;F"%6776f581a4329e299531e1d52aa59832