Created
July 30, 2017 20:30
-
-
Save wilsonllucena/da4973bbeade9eca5e0b4f60074c5ba9 to your computer and use it in GitHub Desktop.
Pegar resultado de ajax em variavel global e usala em dois momentos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OrgaoLotacaoModule.factory('OrgaoLotacaoFactory', ['$resource', | |
function ($resource) { | |
return $resource('/api/con-orgao-lotacao/:id', {}, { | |
get: {method: 'GET'}, | |
save: {method: 'POST', requestType: 'json'}, | |
query: {method: 'GET'}, | |
querySiglas: { | |
method: 'GET', | |
url: '/api/con-orgao-lotacao/?_method=get-siglas' | |
}, | |
remove: {method: 'DELETE'}, | |
delete: {method: 'DELETE'} | |
}); | |
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FiscalModule.controller('FiscalListaController', ['$rootScope', '$route', '$filter', '$scope', '$http', '$timeout', 'uiGridConstants', 'FiscalFactory', 'ContratoFactory', 'OrgaoLotacaoFactory','localStorageService', | |
function ($rootScope, $route, $filter, $scope, $http, $timeout,uiGridConstants, FiscalFactory, ContratoFactory, OrgaoLotacaoFactory,localStorageService) { | |
var siglas; //Auqi a variavel global | |
//Aqui eu estou p=recebendo os dados via ajax na minha factory | |
OrgaoLotacaoFactory.querySiglas(function (response) { | |
siglas = response.result; | |
}); | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.gridOptions.onRegisterApi = function(gridApi){ | |
$scope.gridApi = gridApi; | |
gridApi.rowEdit.on.saveRow($scope, $scope.saveRow); | |
}; | |
$scope.gridOptions.columnDefs = [ | |
{name: 'id', enableCellEdit: false, enableFiltering: false,displayName: '#', width: 60 , | |
cellTemplate: '<div class="ui-grid-cell-contents text-align-right"><a ng-href="#/fiscal/{{COL_FIELD}}">{{COL_FIELD}}</a></div>'}, | |
{name: 'sNome', displayName: 'Fiscal', width: '30%', filter: {condition: _.searchMultiTerms}}, | |
{name: 'sMatricula', displayName: 'Matricula', width: '25%', filter: {condition: _.searchMultiTerms}}, | |
{name: 'bSigla', displayName: 'Orgão Lotação', width: '20%', | |
filterHeaderTemplate: '<div class="ui-grid-filter-container" ng-repeat="colFilter in col.filters"><div select-dropdown-array></div></div>', | |
filter: { | |
options: siglas,//Aqui eu quero usar a variavel global com resultados | |
condition: function(searchTerm, cellValue) { | |
if(!_.isEmptyVar(cellValue)) | |
return cellValue.toLowerCase() == searchTerm.toLowerCase(); | |
}, | |
}, | |
}, | |
{name: 'sNumeroContrato', displayName: 'Numero do Contrato', width: '20%', filter: {condition: _.searchMultiTerms}}, | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment