Just started trying out angular js. I have setup the standard asp.net mvc api controller:
public class ValuesController : ApiController
{
// GET api/values
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
}
I am trying to get those values in my listbox:
<div ng-controller="myctrl">
<select ng-model="selectedValue" ng-options="val for val in getData()">
<option value="">Select</option>
</select>
</div>
Using this script:
var app = angular.module('app', []);
app.controller('myctrl', function ($scope, $http) {
$scope.getData = $http.get('/api/values').then(function (data) {
return data;
});
});
When I run this it does not populate the listbox and jsfiddle:http://jsfiddle.net/dingen2010/t3eXj/