Created
January 29, 2014 02:52
-
-
Save nicksergeant/8680922 to your computer and use it in GitHub Desktop.
Revisions
-
nicksergeant created this gist
Jan 29, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ // Controller. function SearchView($scope, SavedSearches) { // Get all of the user's saved searches. SavedSearches.all().then(function(response) { $scope.savedSearches = response.data; }); // Create a new saved search. $scope.create = function() { var newSavedSearch = SavedSearches.create({ search: 'peanuts' }); } } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ (function(angular, undefined){'use strict'; angular.module('something') .factory('SavedSearches', function($http) { return { all: function() { var promise = $http({ method: 'GET', url: '/api/saved-searches/' }); return promise; }, create: function(savedSearch) { var promise = $http({ method: 'POST', url: '/api/saved-searches/', data: savedSearch }); return promise; }, delete: function(savedSearch) { var promise = $http({ method: 'DELETE', url: '/api/saved-searches/' + savedSearch._id + '/' }); return promise; }, }; }); })(angular);