Custom routing

Yep fuck SPA principle in angular, do it my way
This commit is contained in:
2016-01-26 10:24:57 +01:00
parent 276642a046
commit 5f2208839d
2 changed files with 47 additions and 15 deletions

View File

@@ -1,11 +1,34 @@
angular.module('satbd.satellite.bar', ['ui.bootstrap','ngAnimate']);
angular.module('satbd.satellite.bar').controller('GlobalCtrl', function($scope) {
$scope.location = ''
$scope.location = '';
$scope.isActive = function(location) {
return $scope.location == location
return $scope.location === location
};
$scope.recents = function() {
$scope.location='recents';
$scope.$broadcast('displayRecents')
};
$scope.collections = function() {
$scope.location='collections';
$scope.$broadcast('displayCollections')
};
$scope.authors = function() {
$scope.location='authors';
$scope.$broadcast('displayAuthors')
};
$scope.search = function( query ) {
$scope.location='search';
$scope.$broadcast('displaySearch', query)
};
$scope.$on('recentsReady', function(event) {
$scope.recents();
});
});
@@ -30,12 +53,21 @@ angular.module('satbd.satellite.bar').controller('HelpInstanceCtrl', function($s
angular.module('satbd.satellite.bar').controller('RecentCtrl', function($scope, $http,$log) {
$scope.albumIDs = [ ];
$http.get('/api/recents').success(function(data){
for (var i = 0; i < 10; i++) {
$scope.albumIDs.push(data[i])
}
$scope.clear = function(event) { $scope.albumIDs = [] };
$scope.$on('displayAuthors', $scope.clear);
$scope.$on('displayCollections', $scope.clear);
$scope.$on('displaySearch', $scope.clear);
$scope.$on('displayRecents', function(event) {
$scope.clear();
$log.info('fetching recent albums');
$http.get('/api/recents').success(function(data){
for (var i = 0; i < 10; i++) {
$scope.albumIDs.push(data[i]);
}
});
});
$scope.$emit('recentsReady')
});