ANGULARJS- NG-OPTIONS

0

I have the following combo:

<select data-ng-model="dadosAddContaCamara.camara" data-ng-options="item.codigo as item.descricao for item in controller.listarCamara">

I need the model dataAddContaCamara.camara pass as object values item.code the item.description, but only goes as string.some tip?

    
asked by anonymous 19.06.2015 / 15:14

1 answer

0

When you write in ng-options "item.code the item.description", is saying to the angle "I want the item code but display the item description". If your listarCamara function returns a list of objects, eg:

var lista = [{"codigo":"1","descricao":"item 1"}
            ,{"codigo":"2","descricao":"item 2"}];

You can get the object with "item descriptions item" instead of "item.codigo item.description".

Good luck!

    
20.06.2015 / 14:29