istic-openstack/client/js/controllers/image/image.js
2016-04-27 19:18:34 +02:00

29 lines
881 B
JavaScript
Executable file

/**
* The image controller
*
* @param {$scope} $scope The $scope service from angular
*/
mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', 'Identity','$rootScope', function ($scope, Image, Loading, Identity, $rootScope)
{
// Update view
var callMeAfterGetImage = function () {
$scope.images = Image.getData().images;
Loading.stop();
};
// If user is login try to retrieve data
if (Identity.isAlreadyLogin()) {
if (Image.getData().images == null) {
Loading.start();
Image.getImages(callMeAfterGetImage);
} else {
callMeAfterGetImage();
}
}
$scope.edit=function(image){
$rootScope.$broadcast("editImageEvent", image, Image.getData().axioms);
}
}]);