1
0
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:
Jack Foltz 2018-01-15 11:46:49 -05:00
parent 4aa2dc0011
commit 4093d8c6f3
Signed by: foltik
GPG Key ID: 303F88F996E95541
3 changed files with 32 additions and 1 deletions

View 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;
});
};
}]);

View File

@ -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;

View 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);
});
};
}]);