I'm using below eventClick which is a property of fullCalendar callback. This is triggered every time an event is clicked on the calendar:
calEvent.fullCalendar({ ...
...
...
eventClick: function(calEvent, jsEvent, view) {
scheduleService.get({id: calEvent.id}, function(schedule) {
console.log(schedule);
$scope.userForm.client.name = schedule.client.name;
$scope.openAppointmentDialog();
});
...I'm setting this $scope.userForm.client.name when event is clicked and $scope.openAppointmentDialog() calls below:
$scope.openAppointmentDialog = function () {
ngDialog.openConfirm({
template: 'appointment-form',
//controller: 'ARScheduleCtrl',
//cache: false,
className: 'ngdialog-theme-default',
preCloseCallback: function (value) {
var nestedConfirmDialog = ngDialog.openConfirm({
template: '<p>Are you sure you want to close?</p>' +
'<div>' +
'<button type="button" class="btn btn-default" ng-click="closeThisDialog(0)">No</button> ' +
'<button type="button" class="btn btn-primary" ng-click="confirm(1)">Yes</button>' +
'</div>',
plain: true,
className: 'ngdialog-theme-default'
});
return nestedConfirmDialog;
},
scope: $scope
})
.then(function (value) {
// Perform the save here
if(value === 'Save') {
toaster.pop('success', 'Appointment', 'Appointment has been successfully saved!');
}
}, function (value) {
// Performs cancel actions
if(value === 'Cancel') {
calendar.fullCalendar('removeEvents', $scope.currentEvent.id);
}
});
};The form has ng-model as userForm.client.name but this is never initialized with eventClick. This however works when I set this outside fullCalendar method.
How do I initialize this model field in the ngDialog template inside this callback event?