Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

fix: start watchers after templates have been loaded

  • Loading branch information...
Matt Lewis
Matt Lewis committed Feb 10, 2016
1 parent 30da212 commit b5621dfd75da328b835ef15423cb1524ab9af6f1
Showing with 21 additions and 20 deletions.
  1. +21 −20 src/directives/mwlCalendar.js
@@ -87,28 +87,29 @@ angular
}
}

var eventsWatched = false;

//Refresh the calendar when any of these variables change.
$scope.$watchGroup([
'vm.viewDate',
'vm.view',
'vm.cellIsOpen',
function() {
return moment.locale() + $locale.id; //Auto update the calendar when the locale changes
}
], function() {
if (!eventsWatched) {
eventsWatched = true;
//need to deep watch events hence why it isn't included in the watch group
$scope.$watch('vm.events', refreshCalendar, true); //this will call refreshCalendar when the watcher starts (i.e. now)
} else {
refreshCalendar();
}
});

calendarHelper.loadTemplates().then(function() {
vm.templatesLoaded = true;

var eventsWatched = false;

//Refresh the calendar when any of these variables change.
$scope.$watchGroup([
'vm.viewDate',
'vm.view',
'vm.cellIsOpen',
function() {
return moment.locale() + $locale.id; //Auto update the calendar when the locale changes
}
], function() {
if (!eventsWatched) {
eventsWatched = true;
//need to deep watch events hence why it isn't included in the watch group
$scope.$watch('vm.events', refreshCalendar, true); //this will call refreshCalendar when the watcher starts (i.e. now)
} else {
refreshCalendar();
}
});

}).catch(function(err) {
$log.error('Could not load all calendar templates', err);
});

0 comments on commit b5621df

Please sign in to comment.
You can’t perform that action at this time.