Skip to content

Instantly share code, notes, and snippets.

@josenaldo
Created November 20, 2015 12:16
Show Gist options
  • Save josenaldo/ec0ea89b213597b4410b to your computer and use it in GitHub Desktop.
Save josenaldo/ec0ea89b213597b4410b to your computer and use it in GitHub Desktop.
Controlador segundo o guia de estilo do John Papa
'use strict';
angular
.module('comdominioApp')
.controller('GitHubTaskListController', Controller)
Controller.$inject = ['$scope', 'GitHubService'];
function Controller($scope, GitHubService) {
var vm = this
vm.getTasks = getTasks;
vm.getLabelContent = getLabelContent;
activate();
function activate() {
vm.getTasks();
}
function getTasks() {
GitHubService.allOpenTasks().success(function(data) {
vm.tasks = data;
});
}
function getLabelContent(labels, type) {
for (var i = 0; i < labels.length; i++) {
if (stringStartsWith(labels[i].name, type)) {
return labels[i].name.slice(type.length + 1, labels[i].length);
}
}
return "";
}
function stringStartsWith(string, prefix) {
return string.slice(0, prefix.length) == prefix;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment