【问题标题】:Angular-ui calendar errorAngular-ui 日历错误
【发布时间】:2014-12-25 11:41:01
【问题描述】:

我正在尝试配置 angular-ui 日历,但运行时出现错误。

TypeError: undefined is not a function
at Object.eventsWatcher.onChanged (http://localhost/fisioGest/js/calendar.js:262:41)

我可以看到事件,一切似乎都正常,但是这个错误,我无法点击事件。

这是我的 app.js 的日历控制器:

app.controller('main-controller',function($scope){
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
this.tab=1;
this.titulopagina='Escritorio';
this.selectTab=function(setTab) {
    this.tab=setTab;
};
this.isSelected=function(checkTab) {
    return this.tab===checkTab;
};

  $scope.eventSources = [
[
    {
        "title": 'All Day Event',
        "start": new Date(y, m, d)
     },
     {
        "title": 'Long Event',
        "start": new Date(y, m, d - 5),
        "end": new Date(y, m, d - 2)
    }
  ]
];

$scope.calendarOptions = {
   calendar: {
   height: 500,
   editable: true,
   header: {
     left: 'title',
     center: '',
     right: 'prev,next basicWeek month agendaDay'
   },
 }
};


});

这就是我定义我的日历的方式:

<div id="calendar" ui-calendar="calendarOptions.calendar" ng-model="eventSources " class="p-relative p-10 m-b-20"></div>

【问题讨论】:

    标签: javascript jquery angularjs fullcalendar angular-ui


    【解决方案1】:

    查看calendar.js的来源,有问题的行似乎是...

    event._start = $.fullCalendar.moment(event.start);
    

    您可能缺少moment.js。看看他们的demo page 并确保你已经包含了fullcalendar.js 的所有依赖项(这是在幕后进行繁重工作的库)并且它们以正确的顺序加载......

    <script src="../bower_components/jquery/dist/jquery.js"></script>
    <script src="../bower_components/jquery-ui/ui/jquery-ui.js"></script>
    <script src="../bower_components/moment/moment.js"></script>
    
    <script src="../bower_components/angular/angular.js"></script>
    <script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.9.0.js"></script>
    <script src="../bower_components/fullcalendar/dist/fullcalendar.js"></script>
    <script src="../bower_components/fullcalendar/dist/gcal.js"></script>
    <script src="../src/calendar.js"></script>
    <script src="calendarDemo.js"></script>
    

    【讨论】:

    • 是的,订单是我的错误之一。另一个是我正在使用的库。我从我的引导主题中包含了一些不能与 fullcalendar.js 一起使用的库,谢谢!!
    • 为什么要包含jquery-ui
    猜你喜欢
    • 1970-01-01
    • 2018-09-02
    • 1970-01-01
    • 2016-06-09
    • 2015-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多