I need to list the all objects in the select element and the first object must be selected by default.
This is the controller to get all objects:
$scope.categories = function() {
$http(
{
method : 'GET',
url : '/prodemo/categories'
}).success(
function(data, status, headers, config) {
$scope.categories = data;
}).error(
function(data, status, headers, config) {
});
};
And this is the select element:
<div data-ng-init="categories()">
<select ng-model="category" ng-options="category.name for category in categories"> </select>
</div>