Last active
May 6, 2016 08:37
-
-
Save dohomi/d0ba6abdb30834fb6bba to your computer and use it in GitHub Desktop.
angular-meteor with ui-calendar init
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="eventCalendar" ui-calendar="eventCtrl.calendarConfig" ng-model="eventCtrl.eventSources" calendar="eventCalendar"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Meteor.publish("events",function(start,end){ | |
return Events.find({ | |
$or: [{ | |
start: { | |
$gte: start, | |
$lt: end | |
} | |
}, { | |
end: { | |
$gt: start, | |
$lte: end | |
} | |
}] | |
}); | |
}); |
@sadanandGithub123 Try instaling angular-material package https://atmospherejs.com/angular/angular-material
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 ...