Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. scope.createUser = function (userTypes, userKey, userValue) {
  2.   $mdDialog.show({
  3.     templateUrl: 'views/createUser.tmpl.html',
  4.     parent: angular.element(document.body),
  5.     targetEvent: event,
  6.     clickOutsideToClose: true,
  7.     controller: function (scope, $mdDialog) {
  8.       scope.userTypes = userTypes;
  9.       scope.newUser = {
  10.         userType: userTypes[0]
  11.       };
  12.  
  13.       scope._createUser = function () {
  14.         Auth.createUser({
  15.           email: scope.newUser.email,
  16.           password: scope.newUser.password,
  17.           userType: scope.newUser.userType,
  18.           orgId: userValue
  19.         })
  20.           .$promise
  21.           .then(function (res) {
  22.             toastr.success('User successfully created');
  23.             // outerScope.users.push(res); // this is what i want
  24.             // outerScope.selectedUser = res; // this is what i want
  25.           })
  26.           .catch(function (err) {
  27.             toastr.error('Error creating user: ' + err.statusText);
  28.           });
  29.       };
  30.  
  31.       scope.closeCreateUser = function() {
  32.         $mdDialog.cancel();
  33.       };
  34.     }
  35.   });
  36. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement