Skip to content

Instantly share code, notes, and snippets.

@mitchross
Created September 12, 2015 01:13
Show Gist options
  • Save mitchross/6b93d4912a6a035f3bcb to your computer and use it in GitHub Desktop.
Save mitchross/6b93d4912a6a035f3bcb to your computer and use it in GitHub Desktop.
angular.module('tvbcLogViewerApp.loggerViewer', [
'ngRoute'
])
.constant("LOGGER_API_ROOT", "https://tvbc-logger.herokuapp.com/api")
//.constant("LOGGER_API_ROOT", "http://192.168.1.223:3000/api")
.config(function ($routeProvider) {
$routeProvider
.when('/viewLogs' , {
templateUrl: 'app/loggerViewer/loggerViewer.html'
})
;
})
.factory('searches', function ($http, $log, LOGGER_API_ROOT) {
return {
getSearches: function () {
return $http.get( LOGGER_API_ROOT + '/searchterms')
.then( function (response) {
$log.log(response);
return response.data
})
;
}
};
})
.controller('LoggerViewerController', function(
$log,
$scope,
$http,
LOGGER_API_ROOT,
searches)
{
searches.getSearches().then(function ( searchesResponse ){
$log.log( searchesResponse);
$scope.searchData = searchesResponse;
});
$scope.deleteSearchTerm = function( id )
{
$http.delete( LOGGER_API_ROOT +'/searchterms/' + id )
.success( function (data)
{
$scope.searchData = data;
})
.error ( function (data )
{
console.log('Error: ' + data);
});
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment