text: (function () {
      'use strict'
  
      angular.module('app')
          .service('LocatarioService', LocatarioService);
  
      LocatarioService.$inject = ['$http'];
  
      function LocatarioService($http) {
  
          function findAllOver() {
              return $http.get('http://localhost:8080/api/locatarios/all?order=nome')
                  .then(function (response) {
                      return response.data;
                  });
          }
  
          function findAll(filtro, page) {
              return $http.get('http://localhost:8080/api/locatarios?page=' + page.number +
                      '&size=' + page.size + '&filterField=nome&filterValue=' + filtro)
                  .then(function (response) {
                      return {
                          registros: response.data,
                          total: response.headers('X-Total-Lenght'),
                          pageSize: response.headers('X-Page-Size'),
                          pages: _calcPage(response.headers('X-Total-Lenght'), response.headers('X-Page-Size')),
                          currentPage: response.headers('X-Current-Page')
                      }
                  });
          }
  
          function _calcPage(totalRegistros, tamanhoPagina) {
              var pages = [];
              var num = totalRegistros / tamanhoPagina;
              var actual = 1;
  
              while (num > 0) {
                  pages.push(actual++)
                  num -= 1;
              }
  
              return pages;
          }
  
          function findById(id) {
              return $http.get('http://localhost:8080/api/locatarios/' + id)
                  .then(function (response) {
                      return response.data;
                  });
          }
  
          function insert(registro) {
              return $http.post('http://localhost:8080/api/locatarios', registro)
                  .then(function (response) {
                      return response.data;
                  });
          }
  
          function update(registro) {
              return $http.put('http://localhost:8080/api/locatarios/' + registro.id, registro)
                  .then(function (response) {
                      return response.data;
                  });
          }
  
          function remove(id) {
              return $http.delete('http://localhost:8080/api/locatarios/' + id)
                  .then(function (response) {
                      return response.data;
                  });
          }
  
          return {
              findAll: findAll,
              findAllOver: findAllOver,
              findById: findById,
              insert: insert,
              update: update,
              remove: remove
          }
      }
  
  })();