Solved

angular bind to select

Posted on 2014-09-16
1
136 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

717 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