Skip to content

Instantly share code, notes, and snippets.

@tangorri
Last active December 28, 2015 10:29
Show Gist options
  • Save tangorri/7486691 to your computer and use it in GitHub Desktop.
Save tangorri/7486691 to your computer and use it in GitHub Desktop.
angular.module('App').controller('OnlytomeCtrl',
function ($scope, $cookies, Http, $route, $location, $translate,Profile, Searches, ProfileSegments, TopCategories) {
$scope.mainNav = null;
$scope.subNav = null;
$scope.currentUser = null;
$scope.selectedTopCategory = null;
$scope.searches = [];
Http.authenticate().then( function(){
Profile.load();
TopCategories.load();
Searches.load();
ProfileSegments.load();
});
angular.module('App').factory('TopCategories',
function ($q, Http) {
var topCategories = this.topCategories = {list: []};
var selected = null;
this.load = function() {
Http.query({
method: 'GET',
url: 'topcategories'
}).success(function (data, status, headers, config) {
topCategories.list = data;
}).error(function (data, status, headers, config) {
console.warn('error topCategories loading');
});
};
this.toggleSelection = function(cat) {
Http.query({
method: 'PUT',
url: 'categories/' + cat.id,
data: { selected: cat.selected }
});
};
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment