I have a function where I am trying to filter objects from an array and assign it to the note variable. However, when I run the program, it shows that the note variable is undefined. How can I fix this issue?
Please take a look at the code snippet below:
datepicker.onSelect = function (checked) {
var state = (checked) ? 'selected' : 'unselected';
$scope.calDate = this.toLocaleDateString();
var note = $scope.tooltipsArray.filter(function (items) { return items.date === '$scope.calDate' })[0];
ModalService.showModal({
templateUrl: 'scripts/directives/calendar/calendarModal.html',
controller: 'calendarModal',
inputs: {
calendarDate: $scope.calDate,
calendarNote: null,
dateSelected: state
},
size: 'sm'
}).then(function (modal) {
modal.element.modal();
});
};