Skip to content

Instantly share code, notes, and snippets.

@clouddueling
Last active August 29, 2015 14:00
Show Gist options
  • Save clouddueling/11189801 to your computer and use it in GitHub Desktop.
Save clouddueling/11189801 to your computer and use it in GitHub Desktop.
A service you can create easily instances of and test.
// NOTE: I ripped this out of my app so it's missing some context. Just observe the methodology used.
// This was also incredibly simple to reach 100% testing across the board.
(function() {
'use strict';
angular.module('module.finder', [])
.controller('ModuleFinderCtrl', ['$scope', 'Finder', function($scope, Finder) {
$scope.finder = new Finder();
$scope.finder.loadObjects();
$scope.finder.loadTags();
}])
.factory('Finder', ['ObjectService', function(ObjectService) {
var Finder = function() {
var self = {};
self.filters = {
types: [],
tags: [],
serieIds: [],
orderBy: 'updated_at',
direction: 'DESC',
query: ''
};
self.busy = false;
self.showTypes = false;
self.showTags = false;
self.showSeries = false;
self.page = 1;
self.objects = [];
return self;
};
return Finder;
}])
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment