unserver-unify
Version:
48 lines (39 loc) • 1.23 kB
JavaScript
;
angular.module('bamboo.blog')
.controller('ReplyEditCtrl', function($scope, ApiService, AppConfig, $state, $stateParams) {
this.id = $stateParams.id;
this.config = AppConfig;
var _self = this;
getReplyInfo();
function getReplyInfo() {
ApiService.get('/replies/' + _self.id).then(function(result) {
//console.log(result);
if (result.data.success) {
_self.content = result.data.data.content;
_self.topic_id = result.data.data.topic_id;
} else {
$scope.error = result.data.error;
}
});
}
this.submit = function() {
if (_self.content.length < 10) {
$scope.error = "Content length can not less than 10.";
return;
}
$scope.error = null;
var params = {
id: _self.id,
t_content: _self.content,
};
//console.log(params);
ApiService.post('/replies', params).then(function(result) {
//console.log(result);
if (result.data.success) {
$state.go('index.blogs.detail', { id: _self.topic_id });
} else {
$scope.error = result.data.error;
}
});
};
});