AngularJS + Fullcalendar发送错误类型错误:无法读取属性未定义“__id” [英] AngularJS + Fullcalendar send error TypeError: Cannot read property '__id' of undefined

查看:627
本文介绍了AngularJS + Fullcalendar发送错误类型错误:无法读取属性未定义“__id”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IM。
在控制器中,我已经所著这样的:

im using angular-ui-calendar in my website. In the controller, i have writed this:

    define(['underscore'], function (_) {
    "use strict";

    var SearchController = function ($scope, $location, OrdersService, UsersService) {

        /* config object */
        $scope.uiConfig = {
            calendar: {
                height: 450,
                editable: true,
                firstDay: 0,
                monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
                monthNamesShort: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'],
                dayNames: ['Domingo', 'Lunes', 'Martes', 'Miercoles', 'Jueves', 'Viernes', 'Sabado'],
                dayNamesShort: ['Dom', 'Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Sab'],
                header: {
                    left: '',
                    center: 'title',
                    right: ''
                }
            }
        };
        $scope.eventSources = [$scope.events];

        var getTecnicians = function () {
            UsersService.getTechs().then(function (techs) {
                $scope.technicians = techs;
            });
        };

        var search = function () {
            var searchObject = $scope.$$childHead.searchForm;
            UsersService.getCurrentStatus(searchObject.technician._id, searchObject.selectedStartDate).then(function (result) {
                $scope.states = result[0].states;
                for (var i = 0; i < $scope.states.length; i++) {
                    var event = {};
                    if (i === $scope.states.length - 1) {
                        event = {
                            title: $scope.states[i].status,
                            start: $scope.states[i].date,
                            allday: true
                        };
                    } else {
                        event = {
                            title: $scope.states[i].status,
                            start: $scope.states[i].date,
                            end: $scope.states[i + 1].date
                        };
                    }
                    $scope.events.push(event)
                }
                if (result) {
                    $scope.haveData = true;
                }
            });
        };

        var init = function () {
            $scope.search = search;
            $scope.getTecnicians = getTecnicians();
            $scope.haveData = false;
            $scope.events = [];
        };
        init();
    };

    SearchController.$inject = ["$scope", "$location", "OrdersService", "UsersService"];

    return SearchController;
});

当我点击一个按钮,我做一个GET请求,并从服务器获取,处理它的数据,并生成事件和自用物品摆在我的范围。

When i do click in a button i do a get request and get data from server, process it and generate events objets and put in my scope.

当我完成它,日历告诉我这个错误:

When i finish it, calendar show me this error:

ypeError: Cannot read property '__id' of undefined
    at sourcesFingerprint (http://localhost:8000/bower_components/angular-ui-calendar/src/calendar.js:48:24)
    at Object.changeWatcher.getTokens (http://localhost:8000/bower_components/angular-ui-calendar/src/calendar.js:88:21)
    at Scope.$get.Scope.$digest (http://localhost:8000/bower_components/angular/angular.js:12243:40)
    at Scope.$get.Scope.$apply (http://localhost:8000/bower_components/angular/angular.js:12516:24)
    at done (http://localhost:8000/bower_components/angular/angular.js:8204:45)
    at completeRequest (http://localhost:8000/bower_components/angular/angular.js:8412:7)
    at XMLHttpRequest.xhr.onreadystatechange (http://localhost:8000/bower_components/angular/angular.js:8351:11) 

需要我穿上活动的_id ..?

Need i to put an _id on events..?

推荐答案

我得到了同样的错误,解决它是单向的,initiliaze事件数组
$ scope.events = []
然后进行HTTP请求

I got the same error, one way to fix it is, initiliaze the event array $scope.events=[] and then make the http request

这篇关于AngularJS + Fullcalendar发送错误类型错误:无法读取属性未定义“__id”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆