ANGULARJS- NG-OPTIONS

Asked

Viewed 414 times

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 dataAddContaCamara.camara model to pass values as object item.codigo as item.Description, however it only goes as string.some hint?

  • This might help: [http://answall.com/questions/69933/angularjs-ng-options-utilizar-propriedade-objecto-objecto-valuo-inv%C3%A9s-do-%C3%Adndi][1] [1]: http://pt.stacklowoverf.com/questions/69933/angularjs-ng-options-utilizar-propriedade-proprieddo-like-value-to-Inv%C3%A9s-do-%C3%Adndi

  • solved the problem!! Thanks!

1 answer

0

When you write in ng-options "item.code as item.Description", you are saying for the angular "I want the item code but display the item description". If your function listCamara returns a list of objects, example:

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

You can get the object with "Item as Description" instead of "Item.Code as Item.Description".

Good luck!

Browser other questions tagged

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