Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hiii,

I would like to know how to bind the data to dropdownlist using angularjs.

i have a department table in sql server and i wanted to bind the deptname and deptId to the dropdownlist using angularjs .

How can i do that?

any help in this regard is highly appreciated..

Thanks in Advance..:)
Posted

You could make a ActionMethod that returns a json result and call it form javascript with angular's $http for example. There are lot of examples out there.
 
Share this answer
 
Write a ActionResult Method that returns Json result like following

JavaScript
$scope.deptList = [{deptname:'some name', deptid:'some id'},....]


then bind it like following

HTML
<select ng-model="deptModel" ng-options="dept as dept.deptname for dept in deptList">
</select>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900