Skip to content

Instantly share code, notes, and snippets.

@nicksergeant
Created January 29, 2014 02:52
Show Gist options
  • Select an option

  • Save nicksergeant/8680922 to your computer and use it in GitHub Desktop.

Select an option

Save nicksergeant/8680922 to your computer and use it in GitHub Desktop.

Revisions

  1. nicksergeant created this gist Jan 29, 2014.
    15 changes: 15 additions & 0 deletions routes.js
    Original 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'
    });
    }
    }
    32 changes: 32 additions & 0 deletions services.js
    Original 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);