scheduler with collision in angularjs

I have followed the tutorial to make the scheduler work with angular. I do have a question though.
People can only add an event trough my own form, not via the scheduler itself as they have to choose an image to add to the event.

But this makes that scheduler.collision does not work. I can still add events within the same time span. also if I want to override the checkCollision method, I get an error in the console that this method is unknown.

I don’t really know how to make both work together since I’m new with Angular.

scheduler directive

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){
                 if(collection) {
            
            scheduler.clearAll();
            scheduler.parse(collection, "json");
              
            
           }
     
          }, 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.config.xml_date="%Y-%m-%d %H:%i";
          scheduler.config.dblclick_create = false;
          scheduler.config.drag_create = false;
          scheduler.config.drag_move = true;
          scheduler.config.readonly = false;
          scheduler.config.touch= true; 
          scheduler.config.collision_limit = 1; 
          scheduler.attachEvent("onEventLoading", function(ev){ 
                return scheduler.checkCollision(ev);             
           });
          scheduler.init($element[0], new Date(), "month");
          scheduler.load("agendaController.php", "json");
          var dp = new dataProcessor("agendaController.php");
          dp.init(scheduler); 
          
         
        }
      }
    });

scheduler save_event through php

myAppProfile.controller('addEventController', function($scope,$location, $http) {
		$scope.saveEvent = function() {
             $http({
                   
                    method: 'POST', 
                    url: 'eventController.php',
                    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                    data: { 
                            'begin': $scope.begin + " " + $scope.btijd,
                            'einde': $scope.einde + " " + $scope.etijd,
                            'beschrijving': $scope.beschrijving,
                            'img': $scope.img
                         }
                }).
               
                success(function(data, status) {
                
                    $location.path("/agenda");
    
                }).
             
                error(function(data, status) {
                    alert(data);
                });
        }
	});

Before saving event to the database, you can have code like next

var id = scheduler.addEvent({ event object here }); if (scheduler.getEvent(id)) save_to_database();

addEvent call will trigger the collision checking. If collision occurs then event will not be added to the scheduler.

Yes but where do I put this code? My scheduler is in one directive and the addevent code is in a separate controller. Inside this controller I can not access the scheduler… I’m a bit lost in angular here…

So, you are adding event on a separate page, without the scheduler, right ?
In such case you need to do validation in server side code.
Client side validation can be used when you are adding|updating event in the scheduler, it was not purposed for rejecting duplicate events during data loading.