2016-03-14 23:58:51 +00:00
|
|
|
app.controller('grouplistCtrl', function($scope, ContactService, SearchService, $routeParams) {
|
2016-03-17 19:23:19 +00:00
|
|
|
var ctrl = this;
|
2016-02-12 12:48:46 +00:00
|
|
|
|
2016-03-17 19:23:19 +00:00
|
|
|
var initialGroups = [t('contacts', 'All contacts'), t('contacts', 'Not grouped')];
|
|
|
|
|
|
|
|
ctrl.groups = initialGroups;
|
2016-02-12 12:48:46 +00:00
|
|
|
|
|
|
|
ContactService.getGroups().then(function(groups) {
|
2016-03-17 19:23:19 +00:00
|
|
|
ctrl.groups = _.unique(initialGroups.concat(groups));
|
2016-02-12 12:48:46 +00:00
|
|
|
});
|
|
|
|
|
2016-03-17 19:23:19 +00:00
|
|
|
ctrl.getSelected = function() {
|
|
|
|
return $routeParams.gid;
|
|
|
|
};
|
|
|
|
|
|
|
|
ctrl.setSelected = function (selectedGroup) {
|
2016-03-14 23:58:51 +00:00
|
|
|
SearchService.cleanSearch();
|
2016-03-17 19:23:19 +00:00
|
|
|
$routeParams.gid = selectedGroup;
|
2016-02-18 16:31:46 +00:00
|
|
|
};
|
2016-03-16 19:37:40 +00:00
|
|
|
});
|