unserver-unify
Version:
39 lines (38 loc) • 1.44 kB
JavaScript
;
angular.module('bamboo.class').controller('GroupForumCtrl', function( $scope, ApiService, TopicApi, CommonService,$stateParams, smoothScroll) {
var self = this;
this.publicUrl = ApiService.SHOST + "/public/images/";
this.defaultPersonPhotoUrl = this.publicUrl + "user_icon&48.png";
this.avatarpath = ApiService.PSURL + "/avatar/";
this.classid = $stateParams.classid;
this.getTopics = function(tableState) {
// console.log(tableState);
var limit = parseInt(tableState.pagination.number);
var start = tableState.pagination.start;
var info = {
gId: self.classid,
action: "getgrouptopics",
start: start,
limit: limit,
sort: tableState.sort,
};
TopicApi.GroupApi(info, function(result) {
var total;
console.log(result);
$scope.displayedTopics = result.data.items;
total=result.data.counter;
console.log($scope.displayedTopics);
angular.forEach($scope.displayedTopics, function(topic, index) {
// console.log(topic);
var author = {
id: topic.author_id,
avatar: topic.author.avatar,
}
topic.avatar_url = CommonService.getAvatarSrc(author);
})
tableState.pagination.numberOfPages = parseInt(total / limit + 0.99);
//console.log(tableState.pagination.numberOfPages);
$scope.totalcounter = total;
});
};
});