UNPKG

unserver-unify

Version:

59 lines 1.95 kB
angular.module('bamboo.common').component('courseTeachersComponent', { templateUrl: 'app/directive/course/courseteachers.tpl.html', bindings: { editors: '<', mainclass: '@', divclass1: '@', divclass2: '@', h3style: '@', imgstyle: '@', theme: '@' }, controller: function(UserService, CourseService, ApiService, CommonService) { var vm = this; vm.$onInit = function() { init(); } function init() { var names = vm.editors; if(vm.h3style){ vm.styleObj = JSON.parse(vm.h3style); console.log(vm.styleObj); } if(vm.imgstyle){ vm.imgObj = JSON.parse(vm.imgstyle); } else { vm.imgObj = {'max-height' : '120px'}; } if(!vm.divclass1){ vm.divclass1 = "col-md-4 col-xs-3 no-padding"; } if(!vm.divclass2){ vm.divclass2 = "col-md-8 col-xs-9 padding-left-0"; } var defaultPersonPhotoUrl = "assets/images/default-person-icon.png"; var teacherPicUrl = ApiService.SHOST + "/photo/" + ApiService.RES + "/teachers/"; UserService.getTeachersInfoByLoginnames(names, function(data) { var teacherinfos = {}; vm.editorsInfo = []; angular.forEach(data, function(teacher, index) { if (teacher.photo && !teacher.avatarflag) { teacher.photourl = teacherPicUrl + teacher._id + "/" + teacher.photo; } else if (teacher.avatar) { var user = { id: teacher.userid, avatar: teacher.avatar, } teacher.photourl = CommonService.getAvatarSrc(user); } else { teacher.photourl = defaultPersonPhotoUrl; } vm.editorsInfo.push(teacher); }) CourseService.setEditorInfo(vm.editorsInfo); console.log(vm.editorsInfo); }); } }, controllerAs: 'ctrl', });