+2 votes
1 view
in Web Technology by (47.8k points)

I have read about it in other posts, but I couldn't figure it out.

I have an array,

$scope.items = [

{ID: '000001', Title: 'Chicago'},

{ID: '000002', Title: 'New York'},

{ID: '000003', Title: 'Washington'}, 


I want to render it as:


<option value="000001">Chicago</option>

<option value="000002">New York</option>

<option value="000003">Washington</option>


And also I want to select the option with ID=000002.

I have read select and tried, but I can't figure it out.

1 Answer

+2 votes
by (107k points)
edited by

For working with select using AngularJS's ng-options if you need a custom title for each option, ng-options are not applicable. Instead of that, you can use ng-repeat with options. 

Looking for Angularjs material from basics! Refer to this video on Angularjs provided by Intellipaat:

You can see the code below:-

<select ng-model="myVariable">

<option ng-repeat="item in items"


title="Custom title: {{item.Title}} [{{item.ID}}]"> {{item.Title}}



Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !