Makes album a component.
Should not be a directive, but a simple component
This commit is contained in:
49
webapp/js/components/album/album.js
Normal file
49
webapp/js/components/album/album.js
Normal file
@@ -0,0 +1,49 @@
|
||||
var album = angular.module('satbd.satellite.bar.components.album', [
|
||||
'ui.bootstrap',
|
||||
'ngAnimate']);
|
||||
|
||||
function AlbumCtrl($log,$uibModal,albumService) {
|
||||
var ctrl = this;
|
||||
ctrl.render = false;
|
||||
ctrl.album = {Note :-1};
|
||||
|
||||
albumService.get(ctrl.id)
|
||||
.then(function(data) {
|
||||
ctrl.album = data;
|
||||
ctrl.render = true;
|
||||
}, function(err) {
|
||||
$log.error('Could not fetch album '+ ctrl.id + ' :' +err);
|
||||
});
|
||||
|
||||
ctrl.openAlbumModal = function() {
|
||||
var albumModalInstance = $uibModal.open({
|
||||
templateUrl: 'js/components/album/albumModal.html',
|
||||
controller: 'AlbumModalInstanceCtrl',
|
||||
size: 'lg',
|
||||
keyboard: true,
|
||||
resolve: {
|
||||
album: function() {
|
||||
return ctrl.album;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
album.component('album', {
|
||||
templateUrl: 'js/components/album/album.html',
|
||||
controller: AlbumCtrl,
|
||||
bindings: {
|
||||
id: '=albumId'
|
||||
}
|
||||
})
|
||||
|
||||
album.controller('AlbumModalInstanceCtrl', function($scope,$uibModalInstance,album) {
|
||||
$scope.album = album;
|
||||
$scope.ok = function() {
|
||||
$uibModalInstance.close('');
|
||||
};
|
||||
$scope.getLink = function(n) {
|
||||
return $scope.album[n];
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user