Php Angularjs不断给出TypeError:无法读取属性';dhx#U安全';未定义的

Php Angularjs不断给出TypeError:无法读取属性';dhx#U安全';未定义的,php,mysql,angularjs,Php,Mysql,Angularjs,我正在尝试让dhtmlx事件日历在我的angularjs webapp上运行。我对这一切还是新手,将日历与angularjs和php+mysql(从db获取事件)相结合,在这三者的结合上没有太多的信息 此代码初始化日历: myAppProfile.directive('dhxScheduler', function() { return { restrict: 'A', scope: false, transclude: true, template:

我正在尝试让dhtmlx事件日历在我的angularjs webapp上运行。我对这一切还是新手,将日历与angularjs和php+mysql(从db获取事件)相结合,在这三者的结合上没有太多的信息

此代码初始化日历:

    myAppProfile.directive('dhxScheduler', function() {
  return {
    restrict: 'A',
    scope: false,
    transclude: true,
    template:'<div class="dhx_cal_navline" ng-transclude></div><div class="dhx_cal_header"></div><div class="dhx_cal_data"></div>',

    link:function ($scope, $element, $attrs, $controller){
      //default state of the scheduler
      if (!$scope.scheduler)
        $scope.scheduler = {};
      $scope.scheduler.mode = $scope.scheduler.mode || "month";
      $scope.scheduler.date = $scope.scheduler.date || new Date();

      //watch data collection, reload on changes
      $scope.$watch($attrs.data, function(collection){
        scheduler.clearAll();
        scheduler.parse(collection, "json"); <-- UNDEFINED
      }, true);

      //watch mode and date
      $scope.$watch(function(){
        return $scope.scheduler.mode + $scope.scheduler.date.toString();
      }, function(nv, ov) {
        var mode = scheduler.getState();
        if (nv.date != mode.date || nv.mode != mode.mode)
          scheduler.setCurrentView($scope.scheduler.date, $scope.scheduler.mode);
      }, true);

      //size of scheduler
      $scope.$watch(function() {
        return $element[0].offsetWidth + "." + $element[0].offsetHeight;
      }, function() {
        scheduler.setCurrentView();
      });

      //styling for dhtmlx scheduler
      $element.addClass("dhx_cal_container");

      //init scheduler
      scheduler.init($element[0], new Date(), "month");
      scheduler.load("agendaController.php");
    }
  }
});
myAppProfile.directive('dhxScheduler',function(){
返回{
限制:“A”,
范围:假,
是的,
模板:“”,
链接:函数($scope、$element、$attrs、$controller){
//调度程序的默认状态
if(!$scope.scheduler)
$scope.scheduler={};
$scope.scheduler.mode=$scope.scheduler.mode | |“月”;
$scope.scheduler.date=$scope.scheduler.date | | new date();
//监视数据收集,在更改时重新加载
$scope.$watch($attrs.data,函数(集合){
scheduler.clearAll();

parse(collection,“json”);我怀疑$watch会在初始化之后立即触发事件,然后再将值分配给数据属性

试试这个:

$scope.$watch($attrs.data, function(collection){
  if(collection) {
    scheduler.clearAll();
    scheduler.parse(collection, "json");
  }
}, true);