mirror of
https://github.com/Foltik/Shimapan
synced 2024-12-29 05:11:55 -05:00
Add UserSvc and UserCtrl
This commit is contained in:
parent
4aa2dc0011
commit
4093d8c6f3
9
app/public/panel/controllers/UserCtrl.js
Normal file
9
app/public/panel/controllers/UserCtrl.js
Normal file
@ -0,0 +1,9 @@
|
||||
var angular = require('angular');
|
||||
|
||||
angular.module('UserCtrl', ['UserSvc']).controller('UserController', ['$scope', 'UserService', function($scope, UserService) {
|
||||
$scope.getUsers = function() {
|
||||
UserService.getAllUsers(function(users) {
|
||||
$scope.users = users;
|
||||
});
|
||||
};
|
||||
}]);
|
@ -1,6 +1,6 @@
|
||||
var angular = require('angular');
|
||||
var uirouter = require('angular-ui-router');
|
||||
var app = angular.module('shimapan-panel', ['ui.router', 'AuthSvc', 'ApiSvc', 'InviteSvc', 'ApiCtrl', 'InviteCtrl', 'NavCtrl', 'PanelRoutes']);
|
||||
var app = angular.module('shimapan-panel', ['ui.router', 'AuthSvc', 'ApiSvc', 'InviteSvc', 'UserSvc', 'ApiCtrl', 'InviteCtrl', 'UserCtrl', 'NavCtrl', 'PanelRoutes']);
|
||||
|
||||
app.run(['$rootScope', '$state', '$stateParams', function($rootScope, $state, $stateParams) {
|
||||
$rootScope.$state = $state;
|
||||
|
22
app/public/services/UserSvc.js
Normal file
22
app/public/services/UserSvc.js
Normal file
@ -0,0 +1,22 @@
|
||||
var angular = require('angular');
|
||||
|
||||
angular.module('UserSvc', []).service('UserService', ['$http', function($http) {
|
||||
this.getUser = function(username, cb) {
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: '/api/users/get',
|
||||
params: {username: username}
|
||||
}).then(function(res) {
|
||||
cb(res.data);
|
||||
});
|
||||
};
|
||||
|
||||
this.getAllUsers = function(cb) {
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: '/api/users/get'
|
||||
}).then(function(res) {
|
||||
cb(res.data);
|
||||
});
|
||||
};
|
||||
}]);
|
Loading…
Reference in New Issue
Block a user