import './comment/frCommenter'; import './common/directives/frMarkdown'; import './poll/frPoll'; import './poll/frPollEditorModal'; angular.module('footyroom') .controller('ArticleEditorController', ['$scope', '$http', '$window', function ($scope, $http, $window) { $scope.article = $window.DataStore.article || { status: 'draft', }; $scope.isPosting = false; $scope.publish = function () { if ($scope.isPosting) { return; } $scope.isPosting = true; $http.post($scope.article.id ? '/articles/' + $scope.article.id : '/articles', { title: $scope.article.title, content: $scope.article.content, thumbnailUrl: $scope.article.thumbnailUrl, status: $scope.article.status, isFeatured: $scope.article.isFeatured, }) .then(function (response) { window.localStorage.removeItem('markdownContent'); $window.location = response.data.url; }) .catch(function (response) { $scope.isPosting = false; $scope.errors = response.data.errors; }); }; }]);