unserver-unify
Version:
41 lines (39 loc) • 1.8 kB
JavaScript
angular.module('bamboo.material').controller('MaterialDetailCtrl', function(ApiService, $location, $rootScope,$location,$sce, $stateParams) {
var _self = this;
this.id = $stateParams.id;
this.item = {};
this.photoPath = ApiService.SHOST + '/material/';
this.defaultPhoto = ApiService.SHOST + "/public/images/details.png";
this.tab = 0;
// this.embeded = =ApiService.queryData.embeded;
/* if (ApiService.queryData.embeded) {
$rootScope.hideHeader = true;
} */
console.log($location.absUrl());
this.encodedUrL=encodeURI($location.absUrl())
function getInfo() {
ApiService.get("/publicmaterial/"+_self.id).then(function(result) {
console.log(result);
if (result.data.success) {
_self.item = result.data.data || {};
if (_self.item.audio) {
_self.item.audiourl = $sce.trustAsResourceUrl(_self.photoPath + _self.item._id + '/' + encodeURI(_self.item.audio));
}
_self.imageUrl = _self.item.photo ? _self.photoPath + _self.item._id + '/' + _self.item.photo : _self.defaultPhoto;
if (_self.item.pages) {
console.log(_self.item.pages);
angular.forEach(_self.item.pages, function(page, index) {
if (page.type == "Video" && page.video) {
page.videourl = $sce.trustAsResourceUrl(_self.photoPath + _self.id + '/' + encodeURI(page.video));
} else if (page.type == "Photo" && page.photo) {
page.photourl = _self.photoPath + _self.id + '/' + page.photo;
} else if (page.type == "YouTube" && page.tubeid) {
page.tubelink = $sce.trustAsResourceUrl("https://www.youtube.com/embed/" + page.tubeid + '?&showinfo=0');
}
})
}
}
});
}
getInfo();
});