Access more object-specific data

Asked

Viewed 515 times

1

I made a GET in a table in my database

$scope.corretor = {};

$scope.getData = function (){
    $http.get("http://.php")
    .success(function(data){
        $scope.corretor = data;
        console.log($scope.corretor);
    })
    .error(function(data, status, headers, config){
        console.log(data);
    });
};
$scope.getData();

console log.

Object
AGENCIA: ""
BANCO: ""
CELULAR: ""
CEP: ""
CIDADE: ""
COMPLEMENTO: ""
CONTA: ""
CPF: 
DTNASCIMENTO: ""
EMAIL: ""
ENDERECO: ""
ENDERECO_COMERCIAL: ""
ID_CORRETOR: "1"
NOME: "LUIZ FABIO LIMA DE MEDEIROS"
NUMERO_ENDERECO: ""
RG: 
TELEFONE: 
TIPO_CONTA: ""
UF: "PA"

But what I want to do, is just take the name, and play inside a ng-options

1 answer

4

You’re assigning the return.

$scope.corretor = data; for the corrector variable, that is now your object is inside this variable, in your controller, you can access the property NOME as follows.

$scope.corretor.NOME

in your html you can access.

{{corretor.NOME}}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.