generators/app/templates/client/app/admin(auth)/user/list/edit/edit.controller.js
function update(form) {
      // refuse to work with invalid data
      if (!vm.user._id || form && !form.$valid) {
        return;
      }

      UserService.update(vm.user)
        .then(updateUserSuccess)
        .catch(updateUserCatch);

      function updateUserSuccess(updatedUser) {
        // update the display name after successful save
        vm.displayName = updatedUser.name;
        Toast.show({text: 'User ' + updatedUser.name + ' updated'});
        if (form) {
          form.$setPristine();
        }
      }

      function updateUserCatch(err) {
        Toast.show({
          type: 'warn',
          text: 'Error while updating user ' + vm.displayName,
          link: {state: $state.$current, params: $stateParams}
        });

        if (form && err) {
          form.setResponseErrors(err.data);
        }
      }
    }
function update(form) {
      // refuse to work with invalid data
      if (!vm.user._id || form && !form.$valid) {
        return;
      }

      UserService.update(vm.user)
        .then(updateUserSuccess)
        .catch(updateUserCatch);

      function updateUserSuccess(updatedUser) {
        // update the display name after successful save
        vm.displayName = updatedUser.name;
        Toast.show({text: 'User ' + updatedUser.name + ' updated'});
        if (form) {
          form.$setPristine();
        }
      }

      function updateUserCatch(err) {
        Toast.show({
          type: 'warn',
          text: 'Error while updating user ' + vm.displayName,
          link: {state: $state.$current, params: $stateParams}
        });

        if (form && err) {
          form.setResponseErrors(err.data);
        }
      }
    }
function update ( form ) { // refuse to work with invalid data if ( ! vm . user . _id || form && ! form . $valid ) { return ; } UserService . update ( vm . user ) . then ( updateUserSuccess ) . catch ( updateUserCatch ) ; function updateUserSuccess ( updatedUser ) { // update the display name after successful save vm . displayName = updatedUser . name ; Toast . show ( { text : 'User ' + updatedUser . name + ' updated' } ) ; if ( form ) { form . $setPristine ( ) ; } } function updateUserCatch ( err ) { Toast . show ( { type : 'warn' , text : 'Error while updating user ' + vm . displayName , link : { state : $state . $current , params : $stateParams } } ) ; if ( form && err ) { form . setResponseErrors ( err . data ) ; } } }
Updates a user by using the UserService save method
@param {Form} [form]
Updates a user by using the UserService save method