Advertisement
Guest User

Untitled

a guest
Sep 17th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. var init = function () {
  2. $http({
  3. method: 'GET',
  4. url: 'http://localhost/hrm/public/getUsers'
  5. }).success(function (data) {
  6. angular.forEach(data, function(item){
  7. console.log(item);
  8. $scope.users.push(item);
  9. });
  10. }).error(function (data) {
  11. console.log(data);
  12. }); };
  13. init();
  14.  
  15. $scope.addUser = function (event) {
  16. $mdDialog.show({
  17. controller: DialogController,
  18. parent: angular.element(document.body),
  19. templateUrl: 'views/admin/addUser.html',
  20. controllerAs: 'ctrl',
  21. clickOutsideToClose:true,
  22. targetEvent: event
  23. }).then(function (addUser) {
  24.  
  25. $mdToast.show(
  26. $mdToast.simple()
  27. .textContent("User ajouté avec succès")
  28. .position('top right')
  29. .hideDelay(1500)
  30. );
  31. }, function(cancel) {
  32. });
  33. };
  34.  
  35. $scope.addUser = function () {
  36. if($scope.password == $scope.cpassword){
  37. $http({
  38. method: 'POST',
  39. url: 'http://localhost/hrm/public/saveUser',
  40. data: {email: $scope.email,password: $scope.password}
  41. }).success(function (data) {
  42. $http({
  43. method: 'POST',
  44. url: 'http://localhost/hrm/public/assign-role',
  45. data: {email: $scope.email, name: $scope.selectedItem}
  46. }).success(function (data) {
  47. $scope.users.push(data);
  48. console.log(data);
  49. });
  50. });
  51. }
  52. else {
  53. console.log("password error");
  54. }
  55.  
  56. $mdDialog.hide();
  57. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement