istic-openstack/client/js/controllers/image/image.js
2016-04-17 18:50:05 +02:00

24 lines
703 B
JavaScript

/**
* The image controller
*
* @param {$scope} $scope The $scope service from angular
*/
mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', 'Identity', function ($scope, Image, Loading, Identity)
{
// 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();
}
}
}]);