I have a table of tests in /tests, and I want to be able to permanently hide a specific test by going to /tests/:id/hide. I have a function that does this, I just need to figure out a way to call it without having to invoke a new controller. When doing this, I also want to redirect back to /tests.
angular.module('WebApp.services', []).
factory('riakAPIService', function($http) {
var riakAPI = {};
riakAPI.hideTest = function(key) {
return $http({
// Some code for setting a "hide" flag for this test in the database
});
}
});
Is there a pretty way to call riakAPI.hideTest(id) when the user goes to /tests/:id/hide?
angular.module('WebApp', ['WebApp.controllers','WebApp.services','ngRoute']).
config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$routeProvider.
when("/tests", {templateUrl: "partials/tests.html", controller: "testsController"}).
when("/tests/:id", {templateUrl: "partials/test.html", controller: "testController"}).
otherwise({redirectTo: '/tests'});
}]);