Skip to content

Instantly share code, notes, and snippets.

@dohomi
Last active May 6, 2016 08:37
Show Gist options
  • Save dohomi/d0ba6abdb30834fb6bba to your computer and use it in GitHub Desktop.
Save dohomi/d0ba6abdb30834fb6bba to your computer and use it in GitHub Desktop.
angular-meteor with ui-calendar init
<div id="eventCalendar" ui-calendar="eventCtrl.calendarConfig" ng-model="eventCtrl.eventSources" calendar="eventCalendar"></div>
var getEvents = function(start, end){
// here fetch your data from source and return a valid event array
return [];
}
angular.module("YourApp")
.controller("EventCalendarController", function ($mdDialog, $scope) {
var eventCtrl = this;
var tracker = new Tracker.Dependency();
eventCtrl.eventSources = [];
$meteor.autorun($scope, function () {
tracker.depend();
var start = $scope.view && $scope.view.start;
var end = $scope.view && $scope.view.end;
if (!start || !end) {
return;
}
$meteor.subscribe("events", start, end).then(function (subscriptionHandle) {
var events = getEvents(start, end);
$cal = angular.element("#eventCalendar");
$cal.fullCalendar("removeEvents");
$cal.fullCalendar("addEventSource", events);
subscriptionHandle.stop();
});
});
eventCtrl.calendarConfig = {
viewRender: function (view, render) {
$scope.view = {
start: view.start.toDate(),
end: view.end.toDate()
};
tracker.changed();
}
}
});
var eventStates = function ($stateProvider) {
$stateProvider
.state("events", {
url: "/events",
views: {
content: {
templateUrl: "events.html",
controller: "EventCalendarController",
controllerAs: "eventCtrl"
}
}
});
};
angular.module("YourApp")
.config(eventStates);
Meteor.publish("events",function(start,end){
return Events.find({
$or: [{
start: {
$gte: start,
$lt: end
}
}, {
end: {
$gt: start,
$lte: end
}
}]
});
});
@sadanandGithub123
Copy link

Hii

I am using this package to render Event calender but application throwing this error ---

Error: [$injector:unpr] Unknown provider: $mdDialogProvider <- $mdDialog <- EventCalendarController

Please suggest solution ...

@donedgardo
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment