Solved

angular bind to select

Posted on 2014-09-16
1
132 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

770 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