{"size": 1351, "ext": "js", "max_stars_repo_path": "app/controller/TodoController.js", "max_stars_repo_name": "AlexandrKurochkin/TODOListFE", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/controller/TodoController.js", "max_issues_repo_name": "AlexandrKurochkin/TODOListFE", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/controller/TodoController.js", "max_forks_repo_name": "AlexandrKurochkin/TODOListFE", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 32.1666666667, "max_line_length": 68, "alphanum_fraction": 0.4641006662}
var todoControllers = angular.module('todoControllers', []);

todoControllers.controller('todoTaskEditorCtrl',  [
    '$scope', 
    'Restangular',
    function($scope, Restangular) {
        $scope.tasks = [{id:1,description:"asdasd"}];
        $scope.task = {};
        
        $scope.addTodoTask = function(description) {
            var data = {'description': description};
            Restangular.one('tasks').one('add').customPOST(
                data,
                undefined,
                undefined,
                {"Content-Type":"application/json"}
                ).then(function(response){
                    $scope.tasks = [];
                    $scope.findAll();
                },null)
        };

        $scope.findAll = function() {
            Restangular.one('tasks').get().then(function(response) {
                $scope.tasks = response;
            }, null)
        };

        $scope.remove = function(taskId, index) {
            Restangular.one('tasks').one('remove').customPOST(
                {taskId: taskId},
                undefined,
                undefined,
                {"Content-Type":"application/json"}
                ).then(function(response){
                    $scope.tasks = [];
                    $scope.findAll();
                },null)        
        };

        $scope.findAll();
}]);