有角度的firebase不会反映完整日历视图中的更改

angular firebase doesnt reflect changes on fullcalendar view

本文关键字:日历 视图 firebase      更新时间:2023-09-26

im在我的angular应用程序中使用Firebase(angularfire)和fullcalendar插件,我可以创建新对象并在firebasedb上看到结果,但我在视图中看不到结果(我只有在刷新页面时才能看到它们)。

出于测试目的,我使用fullcalendar的dayClick()事件来触发firebase:的$add功能

控制器:

(function () {
    var app = angular.module("appCal");
    app.controller('meetingsCtrl', meetingsCtrl);
    function meetingsCtrl($scope, $http, $location, $log, $firebaseArray, $timeout) {
        var ref = new Firebase(FIREBASE_URL);
        $scope.fireEvents = $firebaseArray(ref);
        $scope.weekNumbers = true;
        $scope.aspectRatio = 3;
        $scope.editable = true;
        $scope.eventDrop = function (event, delta, revertFunc) {
            // todo event drop
        };
        $scope.dayClick = function (date, jsEvent, view) {
            $scope.fireEvents.$add({ title: 'new meeting...', start: date.format() });
        }
    }
})();

指令:

(function () {
    var app = angular.module("appCal");
    app.directive("sbCalendar", function () {
        return {
            link: function (scope, element, attrs) {
                scope.fireEvents.$loaded(function () {
                    $(element).fullCalendar({
                        header: {
                            left: 'prev,next today',
                            center: 'title',
                            right: 'month,agendaWeek,agendaDay'
                        },
                        eventLimit: scope.weekNumbers,
                        aspectRatio: scope.aspectRatio,
                        events: scope.fireEvents,
                        editable: scope.editable,
                        eventDrop: scope.eventDrop,
                        dayClick: scope.dayClick
                    });
                });
            } 
        } 
    });
})();

查看Angular UI团队是如何做到这一点的。

/*
*  AngularJs Fullcalendar Wrapper for the JQuery FullCalendar
*  API @ http://arshaw.com/fullcalendar/
*
*  Angular Calendar Directive that takes in the [eventSources] nested array object as the ng-model and watches it deeply changes.
*       Can also take in multiple event urls as a source object(s) and feed the events per view.
*       The calendar will watch any eventSource array and update itself when a change is made.
*
*/

https://github.com/angular-ui/ui-calendar/blob/master/src/calendar.js