Display images in select dropdown

10,187 views
Skip to first unread message

Jeevan Chamarthi

unread,
Jun 9, 2014, 5:13:32 AM6/9/14
to ang...@googlegroups.com
Hi,
We are trying to fetch images from the model values and construct the images in the select dropdown but that doesn't work with the following approach.

Please suggest. 

<select ng-model="mobileoperators">
    <option ng-repeat="operator in operators" data-image="/home/images/{{operator.name}}.png">{{operator.name}}</option>
<select>

Thanks, Jeevan

SamLR

unread,
Jun 9, 2014, 5:29:59 AM6/9/14
to ang...@googlegroups.com
Hi Jeevan, 

I'm not sure I fully understand what you're trying to do. Is data-image a directive, if so what does it do? If you're trying to set the content of `mobileoperators` then you need to chance `data-image` to `value` and it will be set.

It's worth noting that the option tag can only contain text. If you want to produce options lists with images attached you'll need to use something like ui-select2's[1] templating. The select2[2] documentation has a good example of this.

I hope this helps. 

S



--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Jeevan Chamarthi

unread,
Jun 10, 2014, 1:31:30 AM6/10/14
to ang...@googlegroups.com
Thanks Sam, that's what we are looking for 'select2' to construct and project images in a dynamic fashion during ng-repeat and using select dropdown.

Hai Huynh

unread,
Nov 6, 2015, 4:59:04 AM11/6/15
to AngularJS
Checkout a example at  http://angularjsaz.blogspot.com/2015/11/angularjs-select-option-with-image.html

Vào 16:13:32 UTC+7 Thứ Hai, ngày 09 tháng 6 năm 2014, Jeevan Chamarthi đã viết:
Reply all
Reply to author
Forward
0 new messages