Solved

angular bind to select

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

760 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

18 Experts available now in Live!

Get 1:1 Help Now