frCommentFlaggerComponent.js
788 Bytes
angular.module('footyroom')
.component('frCommentFlagger', {
templateUrl: '/views/ng/comments/commentFlagger.html',
bindings: {
commentId: '@',
dismiss: '&',
},
controller: ['$http', function ($http) {
var ctrl = this;
ctrl.submit = submit;
function submit() {
ctrl.voting = true;
$http.post('/comments/' + ctrl.commentId + '/flag', {
flagName: ctrl.selectedChoice,
})
.then(function () {
ctrl.success = true;
})
.catch(function (response) {
ctrl.errors = response.data.errors;
})
.finally(function () {
ctrl.voting = false;
});
}
}],
});