This is the main controller for handling event maps.
.controller('EventMapCtrl', function($scope, $stateParams, Events) {
var vm = this;
vm.EventId = Number($stateParams.id);
Events.getEvents.then(function(data) {
vm.event = _.find(data, {id: vm.EventId});
console.log(vm.event);
});
$scope.vm = vm;
});
This is the Events
service that retrieves event data from the API.
.service('Events', function(mApi, mDomain) {
return {
getEvents: mApi.getData('/events/')
}
});
Currently, I am able to fetch all events using an HTTP call. However, in the controller, my goal is to filter and display only one event with an ID matching vm.EventId
. At the moment, I encounter an undefined error when trying to log vm.event
. Any assistance would be greatly appreciated. My knowledge of Angular is relatively new, and I'm unsure if my use of .find()
is correct.