Solved

AngularJS need to set selected value

Posted on 2013-11-26
2
448 Views
Last Modified: 2013-11-26
I have a select that is being filled with information from a database.  after it is full I need to select an agent in the list and set it as selected

<select id="WMRAgents" ng-model="wmrAgents" ng-options="agent as agent.ListingAgentName for agent in agents">
	<option value="">View All Agents</option>
</select> 

Open in new window


controller.js

var wmrAgentsResult = ListingsService.getAgentsByManager(
	{ "UserId": userID }
	, function (xhttp, responseHeaders) {
		$scope.agents = wmrAgentsResult;	
	}
	, function (data, status) {
		$scope.listingsLoading = false;
	}
);

Open in new window



data

ListingAgentId          ListingAgentName
2                            Tom Smith
6                            Mary Jones
0
Comment
Question by:charlesbaldo
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39678894
Try this :
var wmrAgentsResult = ListingsService.getAgentsByManager(
	{ "UserId": userID }
	, function (xhttp, responseHeaders) {
		$scope.agents = wmrAgentsResult;
                $scope.wmrAgents = $scope.agents[0];
	}
	, function (data, status) {
		$scope.listingsLoading = false;
	}
);

Open in new window

0
 

Author Closing Comment

by:charlesbaldo
ID: 39678946
Thanks Once again, your expertise has shown to be top notch
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

This article will show, step by step, how to integrate R code into a R Sweave document
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

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