%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/news/public/scripts/controllers/modals/
Upload File :
Create Path :
Current File : //var/www/html/news/public/scripts/controllers/modals/comments.controller.js

'use strict';

angular.module('controllers').controller('modalCommentsController', function ($scope, article, $uibModalInstance, resource, notification, modalService) {

    $scope.article = article;

    $scope.approve = function (comment) {
        resource.forResource('articles/' + $scope.article.id + '/comments/' + comment.id + '/actions/approve').save().then(function (res) {
            comment.is_approved = true;
        }, function (error) {
            notification.error(error);
        })
    };

    $scope.delete = function (comment) {
        modalService.modalConfirmation().then(function () {
            resource.forResource('articles/' + $scope.article.id + '/comments').delete(comment.id).then(function () {
                notification.success('Comment deleted successfully');
                $scope.article.comments.splice($scope.article.comments.indexOf(comment), 1);
            }, function (error) {
                notification.error(error);
            });
        });
    };

    $scope.cancel = function () {
        $uibModalInstance.close();
    };

});

Zerion Mini Shell 1.0