I am trying this code in angularJs:
app.controller('controlselect', function($scope, $http) {
$scope.provinces = [];
$http({
method: 'GET',
url: './api.php?accion=provinces'
}).success(function (result) {
$scope.provinces = result;
});
And this the html to show this:
<select ng-model="province.idprovince" data-ng-options="province.idprovince as province.province for province in provinces"></select>
Object's example filled in:
provinces:
[ {provinceid: '1', province: 'Option A'}, {provinceid: '2', province: 'Option B'}, {provinceid: '3', province: 'Option C'} ]
If I like to show an ng-repeat="province in provinces" this works good, but when I Try the ng-options on select no work.
Any idea?
Thanks!
Here is the working example http://dojo.telerik.com/ayimI You have do transformation for your json array as
$scope.provinces = [{"idprovince": "1", "province": "name"}];
Hope this mat help you.