-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.controller.js
More file actions
31 lines (26 loc) · 1019 Bytes
/
user.controller.js
File metadata and controls
31 lines (26 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
(function () {
var app = angular.module('plunker');
app.controller('UserCtrl', function ($scope, swapiService, $routeParams) {
var onUserComplete = function (response) {
$scope.typeListInfo = response;
swapiService.getPeople($scope.type)
.then(
function (instances) {
$scope.instances = instances.map(function (val, idx) {
val.id = val.url.match(/[0-9]*(?=[^[0-9]*]*$)/).pop();
return val;
});
},
onError
);
}
var onError = function (reason) {
$scope.error = "Nie udalo sie pobrac: " + JSON.stringify(reason);
}
$scope.type = $routeParams.type;
$scope.repoSortOrder = "mass";
$scope.repoSortOrderType = "1";
swapiService.getType($scope.type)
.then(onUserComplete, onError);
});
})();