'use strict';

/** 
 * @controller ArticleDetailsController
 * @property scope 
 * @property route
 * @property location
 * @property System
 * @property ArticleService
 * @property Resource
 */

var ArticleDetailsController = angular.module('articles.controllers.details', [
    'system'
])
    .controller('ArticleDetailsController', [
        '$scope',
        '$route',
        '$location',
        'System',
        'ArticleService',
        function($scope, $route, $location, System, ArticleService) {
            var id = $route.current.params["id"];

            /**
            * @method refresh
            * @description Gets initial data
            */
            $scope.refresh = function() {
                ArticleService.get(id)
                    .then(function(data) {
                        $scope.article = data; 
                    });
            };

            /**
             * @action back returns to location /articles
             */
            $scope.back = function() {
                $location.url('/articles');
            };

            $scope.refresh();

        }
    ]);