• Post Reply Bookmark Topic Watch Topic
  • New Topic

Angularj Select Get Complete Object

 
chicha sonu
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am using Angularjs with Select as below

objArr=
[{"key":"A","key1":"B","value":"C"}
{"key":"D","key1":"E","value":"F"}
{"key":"G","key1":"H","value":"I"}
{"key":"J","key1":"K","value":"L"}];

<select chosen id="myModel" class="chosen-select"  ng-model="myModel" ng-options="obj.key as obj.value for obj in objArr"  ng-change="onChange()" required >
<option value=""></option>
</select>

1)Now On Change i get only key,where as i need complete object to manipulate other fields based on the key key1 and value,which i am unable to do
2)I am unable to set the default value into the combo

Please help me with the same
Thanks in Advance
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's the way selects work. You'll need to look up the object by key.

It's not a "combo" -- it's a select. You should be able to initialize it by having the proper key in the ng-model variable.
 
chicha sonu
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you Please provide me a working example.That would help me a lot
Thanks in Advance
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Give it a try yourself and post back with specific problems that you are having.
 
chicha sonu
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as described in the post, i am unable to set the value to the combo

Thanks in Advance
 
chicha sonu
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for a selection i need to get key,key1 and value

Thanks in Advance
 
chicha sonu
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And also i need to set the value to combo
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I;ve already answered those questions. Please try using the approaches in code and post it (use code tags) with any problems that you are having.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!