(function () { "use strict"; angular.module('streamApp').controller("memoryAddController", MemoryAddController); MemoryAddController.$inject = ['$scope', 'userService', '$location', '$routeParams', 'timelineService']; function MemoryAddController($scope, userService, $location, $routeParams, timelineService) { if ($routeParams.questionId) { if ($routeParams.timelineId) { timelineService.getAvailablePrompts($routeParams.timelineId) .then((prompts) => { $scope.prompt = prompts.find(p => p.promptId == $routeParams.questionId); }); } else { userService.getPrompt($routeParams.questionId).then(prompt => $scope.prompt = prompt ); } } if ($routeParams.timelineId) { timelineService.get($routeParams.timelineId).then((timeline) => { $scope.timeline = timeline; }); } $scope.callback = function () { if ($scope.timeline) { $location.url('/timelines/' + $scope.timeline.Id); } else { $location.url('/'); } }; } })();