Created
November 20, 2015 12:16
-
-
Save josenaldo/ec0ea89b213597b4410b to your computer and use it in GitHub Desktop.
Controlador segundo o guia de estilo do John Papa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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