Solved

AngularJS need to set selected value

Posted on 2013-11-26
2
439 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

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

863 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

27 Experts available now in Live!

Get 1:1 Help Now