se-hub/templates/js/controllers/tasksController.js

32 lines
946 B
JavaScript
Raw Normal View History

angular.module('SeHub')
.controller('tasksController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope)
{
2015-08-02 12:39:39 +00:00
$scope.lecturerTasks = [];
$rootScope.seToken = $cookies['com.sehub.www'];
var token = $rootScope.seToken;
$scope.createTaskClicked = function()
{
2015-06-24 10:42:32 +00:00
$location.path("/tasks/new"); // Reference to 'newTask' page
}
2015-08-02 12:39:39 +00:00
$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);
}
2015-08-02 12:39:39 +00:00
$scope.displayTasks(); // Calling tasks with task id
}]);