Solved

angular bind to select

Posted on 2014-09-16
1
131 Views
Last Modified: 2014-09-16
I am having an issue binding to an array of objects using a select input.  I can use a repeater, but I can't get the select to work.

    $scope.suggestedstrategyfocusarea = [
        { name: "Strategy 1", age: 1 },
        { name: "Strategy 2", age: 1 },
        { name: "Strategy 3", age: 1 },
        { name: "Strategy 4", age: 1 }
    ];
<select id="suggestedstrategyfocusarea" ng-options="option.name for options in suggestedstrategyfocusarea"></select>

this does work however
<li ng-repeat="option in suggestedstrategyfocusarea">
      {{option.name}} = {{option.age}}
</li>
0
Comment
Question by:jackjohnson44
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40325652
Test page : http://jsfiddle.net/m2vmy1gh/

for option <--- no "s"
and you MUST have a  ng-model="strategy"

<select ng-model="strategy" ng-options="option.name for option in suggestedstrategyfocusarea"></select>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now