Angular select with images

All we need is an easy explanation of the problem, so here it is.


I need to insert flags inside the language select. I have searched in Google and StackOverflow but the solutions founded are not working for me.


In the controller:

 $scope.language_list = [{'name': 'english', 'url': ''},{'name': 'italian', 'url': ''}];

In the view:

<select ng-model="language_selected">
    <option ng-repeat="language in language_list" data-image="{{language.url}}" >{{}}</option>



How can i insert images inside the angular select?


Here is the Plunker of the solution, cleaned up:

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

As other answers you can not use <options> to add an image, however you can use angular module ui-select to achieve what you want to do.

Here is a demo with ui-select with your data.

Clean up the code and get what you need.

If you’re not interested in search box override the CSS as,

 .select2-search {
      display: none;


Method 2

this is impossible with a native select element,

therfore, you need to design a selectbox using other html elements & css,

try this out:

var app = angular.module('app',[]);

//app.directive('appDirective', function() {});
//app.factory('appService', function() {});

function AppCtrl($scope) {
	$scope.obj={language_selected : {'name':'Choose a language'}};
    $scope.language_list = [{'name': 'english', 'url': ''},{'name': 'italian', 'url': ''}];
    background-color: #fff;
    border: 1px solid #b3b3b3;
    cursor: pointer;
    height: 21px;
    line-height: 21px;
    padding: 3px 5px;
    position: relative;
    vertical-align: middle;
    width: 250px;
.select_list > .options{
    border:1px solid #666;
} > .options{

.select_list > span, .select_list > .options li {
    background-position: 5px center;
    background-repeat: no-repeat;
    padding-left: 30px;

.select_list > .options li:hover {
<script src=""></script>
<div ng-app="app"  ng-controller="AppCtrl">
<div class="select_list" ng-class='{active:active}' ng-click="active=!active">
    <span ng-style="{'background-image':'url('+obj.language_selected.url+')'}">{{}}</span>
    <ul class="options">
        <li class="select_list_option" ng-repeat="language in language_list" ng-click="obj.language_selected=language" ng-style="{'background-image':'url('+language.url+')'}">{{}}</li>

Method 3

The Answer:

Its simply not possible.

The permitted content of a <option> tag is Text with eventually escaped characters (like &eacute;).
HTML isnt allowed.

See the docs for more information.

The solution:

Make a custom Dropdown with CSS and HTML.

Method 4

It’s not possible, as <option> only supports text.

You may have to roll your own drop-down control using complex HTML/CSS/JavaScript. How to do it may or may not be within the scope of your question.

Alternatively, you may use a non-repeating background-image and apply some padding on the text to achieve a similar effect. But if each <option> is to have a unique image, your code is going to be polluted with a style attribute for every single <option>. If you don’t mind that, it’s fine. Otherwise, roll your own somehow.

Referred from : Adding images with option tag

Method 5

Instead of inserting images you could generate css classes (from the language name or adding a new value only for that) and add the images as background images in your css (using sprites).

<select ng-model="language_selected">
    <option ng-repeat="language in language_list" ng-class="{{ }}" >{{ }}</option>

For the css sprites I usually use sass with compass.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply