CleverStack/angular-seed

View on GitHub
app/modules/roles/services/RoleService.js

Summary

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

  ng
  .module('roles.services')
  .factory('RoleService', function(RoleModel) {
    var RoleService = {

      model: RoleModel,

      data: null,

      list: function(findOptions) {
        return RoleModel.list(findOptions).$promise.then(function(roles) {
          RoleService.data = roles;
          return RoleService.data;
        });
      },

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

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

    return RoleService;
  });
});