se-hub/templates/js/controllers/tasksController.js
2015-08-02 15:39:39 +03:00

32 lines
No EOL
946 B
JavaScript

angular.module('SeHub')
.controller('tasksController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope)
{
$scope.lecturerTasks = [];
$rootScope.seToken = $cookies['com.sehub.www'];
var token = $rootScope.seToken;
$scope.createTaskClicked = function()
{
$location.path("/tasks/new"); // Reference to 'newTask' page
}
$scope.displayTasks = function()
{
apiService.getAllFutureTasks(token).success(function(data) // Get all Tasks // TODO change to closest TASK
{
$scope.lecturerTasks = data;
console.log(data);
}).error(function(err)
{
console.log(err.message);
});
}
$scope.gotoTask = function(taskId)
{
$location.path('/tasks/fill/' + taskId);
}
$scope.displayTasks(); // Calling tasks with task id
}]);