Given this module and controller
angular.module('contactServices', ['ngResource']).
factory('ApiKey', function ($resource) {
return $resource('/V1/apikeys', {}, {
query: {method: 'GET', params: {}, isArray: false}
});
});
function ContactCtrl($scope, ApiKey) {
$scope.keys = ApiKey.query();
}
which returns this data
{ myObject: [{ id: "1", value: "Value1" }, { id: "2", value: "Value2" }, { id: "3", value: "Value3" }] }
to this html element
<select style="width:350px;" tabindex="2">
<option ng-repeat="k in keys" value="{{k.id}}" >{{k.value}}</option>
</select>
When the page loads the resource grabs the data, but it returns a promise, which I understand conceptually, and can see that it has returned data (at a later time than the loading of the page), but the select is never loaded. At one point, I had used the $http service and had this working, but that was some time ago and I really like to use the resource abstraction if possible.
Thank you, Stephen
Update
Based on the comments here is the updated working example. The actual fix was to grab the json object and look for the apiKeys object.
<select ng-model="keys" ng-options="k.value for k in keys"></select>
function ContactCtrl($scope, ApiKey) {
ApiKey.query({}, function (data) {
$scope.keys = data.apiKeys; <<<<<<<<<<========= the fix
});
}