Files
meanTorrent/modules/forums/client/controllers/forums-topic.client.controller.js

63 lines
1.7 KiB
JavaScript
Raw Normal View History

2017-07-08 01:40:20 +08:00
(function () {
'use strict';
angular
.module('forums')
.controller('ForumsTopicController', ForumsTopicController);
ForumsTopicController.$inject = ['$scope', '$state', '$translate', 'Authentication', 'MeanTorrentConfig', 'ForumsService', 'SideOverlay', '$filter', 'NotifycationService',
'marked', 'ModalConfirmService', '$stateParams', 'TopicsService'];
function ForumsTopicController($scope, $state, $translate, Authentication, MeanTorrentConfig, ForumsService, SideOverlay, $filter, NotifycationService,
marked, ModalConfirmService, $stateParams, TopicsService) {
var vm = this;
vm.forumsConfig = MeanTorrentConfig.meanTorrentConfig.forumsConfig;
vm.user = Authentication.user;
vm.forumPath = [];
2017-07-08 10:17:20 +08:00
/**
* If user is not signed in then redirect back home
*/
if (!Authentication.user) {
$state.go('authentication.signin');
}
2017-07-08 01:40:20 +08:00
/**
* init
*/
vm.init = function () {
// get forum info by state params
ForumsService.get({
forumId: $stateParams.forumId
}, function (item) {
vm.forum = item;
vm.forumPath.push({name: vm.forum.name, state: 'forums.view', params: {forumId: vm.forum._id}});
});
// get topics
TopicsService.get({
forumId: $stateParams.forumId,
topicId: $stateParams.topicId
}, function (topic) {
console.log(topic);
vm.topic = topic;
vm.forumPath.push({name: topic.title, state: undefined});
});
};
2017-07-08 10:17:20 +08:00
/**
* getTopicContent
* @param t
* @returns {*}
*/
vm.getTopicContent = function (t) {
if (t) {
return marked(t.content, {sanitize: true});
}
};
2017-07-08 01:40:20 +08:00
}
}());