1 |
56360
|
michele.ar
|
var orgsModule = angular.module('orgs', ['ngRoute']);
|
2 |
|
|
|
3 |
|
|
orgsModule.config(function($routeProvider) {
|
4 |
|
|
$routeProvider
|
5 |
|
|
.when('/new', { templateUrl: 'html/new.html', controller: 'newOrgCtrl' })
|
6 |
|
|
.when('/search', { templateUrl: 'html/search.html', controller: 'searchCtrl' })
|
7 |
|
|
.when('/countries', { templateUrl: 'html/browse.html', controller: 'countriesCtrl' })
|
8 |
|
|
.when('/byCountry/:code/:page/:size', { templateUrl: 'html/list.html', controller: 'byCountryCtrl' })
|
9 |
|
|
.otherwise({ redirectTo: '/search' });
|
10 |
|
|
});
|
11 |
|
|
|
12 |
|
|
orgsModule.controller('newOrgCtrl', function ($scope, $http, $routeParams) {
|
13 |
|
|
|
14 |
|
|
});
|
15 |
|
|
|
16 |
|
|
orgsModule.controller('searchCtrl', function ($scope, $http, $routeParams) {
|
17 |
|
|
|
18 |
|
|
});
|
19 |
|
|
|
20 |
|
|
orgsModule.controller('countriesCtrl', function ($scope, $http, $routeParams) {
|
21 |
|
|
$scope.field = 'Country';
|
22 |
|
|
$scope.entries = [];
|
23 |
|
|
|
24 |
|
|
$http.get('/api/organizations/browse/countries').then(function successCallback(res) {
|
25 |
|
|
$scope.entries = res.data;
|
26 |
|
|
}, function errorCallback(res) {
|
27 |
|
|
alert("Errore");
|
28 |
|
|
});
|
29 |
|
|
|
30 |
|
|
});
|
31 |
|
|
|
32 |
|
|
orgsModule.controller('byCountryCtrl', function ($scope, $http, $routeParams) {
|
33 |
|
|
$scope.basepath = '/byCountry/' + $routeParams.code;
|
34 |
|
|
|
35 |
|
|
$scope.orgs = [];
|
36 |
|
|
|
37 |
|
|
$http.get('/api/organizations/byCountry/' + $routeParams.code + '/' + $routeParams.page + '/' + $routeParams.size).then(function successCallback(res) {
|
38 |
|
|
$scope.orgs = res.data;
|
39 |
|
|
}, function errorCallback(res) {
|
40 |
|
|
alert("Errore");
|
41 |
|
|
});
|
42 |
|
|
});
|