Angular UI-Calendar TypeError: calendar.fullCalendar is not a function

依然范特西╮ 提交于 2020-01-02 18:16:33

问题


I been trying to use Angular: ui-calendar with meteor, but get this error.

TypeError: calendar.fullCalendar is not a function
    at Scope.scope.initCalendar (calendar.js:265)
    at Object.fn (calendar.js:337)
    at Scope.$digest (angular.js:15896)
    at Scope.$apply (angular.js:16160)
    at bootstrapApply (angular.js:1679)
    at Object.invoke (angular.js:4523)
    at doBootstrap (angular.js:1677)
    at Object.bootstrap (angular.js:1697)
    at HTMLDocument.onReady (app.js:47)
    at fire (jquery.js:3143)

In meteor packages i habe:

angular 1.2.3 angularui:ui-calendar

also tried to use the package inserted directly not using meteor add. but using the calendar.js file (which is different)

Both get the same error.

Tried this: https://github.com/angular-ui/ui-calendar/issues/267

       scope.initCalendar = function () {
                if (!calendar) {
                    calendar = $(elm);
                }
                calendar.fullCalendar(options);
                if (attrs.calendar) {
                    uiCalendarConfig.calendars[attrs.calendar] = calendar;
                }
         };

But is seems this fix doesnt work with meteor and angular-meteor.

Any ideas on how to fix this issue?


回答1:


You should check the initCalendar and destroyCalendar methods in angular-ui-calendar/src/calendar.js. If they're creating the element by using:

angular.element(elm).html('');

Then you should replace it by:

$(elm).html('');



回答2:


the problem is that angular doesn't find jquery in window.$

if you are using es6 modules:

import jquery from "jquery";

export default (window.$ = window.jQuery = jquery);

otherwise you should add js script in you index.html and before your app code:

window.$ = window.jQuery = jquery



回答3:


I think you may not have correctly configured the controller for your page?

I had this same issue but using ui-router, I had the controller specified incorrectly and it wasn't being wired up. Fixing this made the calendar appear and this error go away.



来源:https://stackoverflow.com/questions/35076867/angular-ui-calendar-typeerror-calendar-fullcalendar-is-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!