CleverStack/angular-seed

View on GitHub
app/modules/auth/services/UserService.js

Summary

Maintainability
B
6 hrs
Test Coverage
define(['angular', '../module'], function(ng) {
  'use strict';

  ng
  .module('auth.services')
  .factory('UserService', function(UserModel) {
    var UserService = {
      model: UserModel,

      data: null,

      list: function(findOptions) {
        return UserModel.list(findOptions).$promise.then(function(users) {
          UserService.data = users;
          return UserService.data;
        });
      },

      get: function(findOptions) {
        return UserModel.get(findOptions).$promise;
      },

      create: function(data) {
        return UserModel.create(data).$promise;
      },

      confirm: function(data) {
        return UserModel.confirm(data).$promise;
      }
    };

    return UserService;
  });

});