I have this code
function GuestWizardController($scope, ApiResourceBed, ApiResourceRoom) {
$scope.rooms = ApiResourceRoom.query();
$scope.showBeds = function( roomId ){
$scope.beds = ApiResourceBed.query();
};
var vm = this;
vm.data = {}
}
ApiResourceBed and ApiResourceRoom are two factories.
I need a select element with all rooms listed. So far, so good.
The thing is that, when I select a room, it triggers showBeds function. Now, I need a way to filter the beds array. So, in a second select element, I can present only the beds asociated to the selected room.
I'm quite new to angular. Any ideas?
UPDATE
ApiResourceBed factory declaration:
.factory('ApiResourceBed', ['APP', '$resource', function( APP, $resource, id ){
return $resource( APP.API_REST + 'beds/:id');
}])
$resource
configuration forApiResourceBed
. You passroomId
to your function but not to$resource