Skip to content

Instantly share code, notes, and snippets.

@hugoalmeidahh
Last active August 29, 2015 14:10
Show Gist options
  • Save hugoalmeidahh/fe0aecb6f25326a15201 to your computer and use it in GitHub Desktop.
Save hugoalmeidahh/fe0aecb6f25326a15201 to your computer and use it in GitHub Desktop.
============= minha combo html =====================
div class="form-group" >
<label for="recipient-name" class="control-label">Empresa Padrão:</label>
<select class="form-control" data-ng-model="x.currentId"
data-ng-options="empresa.nome for empresa in empresas">
</select>
</div>
===================================================
================== meu angular ====================
//popular a combo: DETALHE ESSE EU JÁ CONSIGO FAZER TRANQUILO!
$scope.carregaEmpresa = function () {
masterAPI.getEmpresa().success(function (dataEmpresas) {
//var sEmpresa = angular.fromJson(dataEmpresas);
//$scope.empresas = sEmpresa;
$scope.empresas = dataEmpresas;
console.log($scope.empresas);
});
};
// setar item ativo na combo: ELE NÃO SETA A COMBO
$scope.getParams = function(){
$http.get("web/core/components/home/alterarParametros.json")
.success(function(data) {
//var o = JSON.parse(data);
var sX = "";
$.each(data, function (key, item) {
//$scope.empresa = item;
//console.log($scope.empresa.currentId);
$scope.x = item;
console.log($scope.x);
});
//console.log($scope.x);
});
};
===================================================
arquivo json (empresa)
[ {
"id": 1,
"nome": "Diocese de São José dos Campos"
}, {
"id": 2,
"nome": "MULTICONTAS DEMONSTRAÇÃO ME"
}, {
"id": 3,
"nome": "TESTE 3"
}, {
"id": 4,
"nome": "TESTEE 4"
}]
arquivo json(parametros)
[ { "manterParceiro": "true", "exibirAjuda": "false", "novaAba": "false", "currentId": {"nome": "TESTE 3"} }]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment