Guy Z
Guy Z

Reputation: 693

Fullcalendar ui-calendar configuration not being read

I'm starting to use fullcalendar ui-calendar (the angular version).

    var app = angular.module('MyApp', ['ui.calendar'])
    .controller('MainController', function ($scope) {

    var events = [
        { title: "event1", start: new Date(2015, 6, 21) },
        { title: "event2", start: new Date(2015, 7, 31), end: new Date(2015, 8, 02) },
        { title: "event3", start: new Date(2015, 8, 01) },
    ];

    $scope.eventSources = [events];

    $scope.calOptions = {

        editable: true,
        header: {
            left: 'prev',
            center: 'title',
            right: 'next'
        }
    };
});


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<link href="Scripts/fullcalendar-2.3.2/fullcalendar.css" rel="stylesheet" />
<script src="Scripts/jquery-2.1.4.min.js"></script>
<script src="Scripts/jquery-ui-1.11.4.min.js"></script>
<script src="Scripts/moment.js"></script>
<script src="Scripts/angular.js"></script>
<script src="Scripts/fullcalendar-2.3.2/fullcalendar.js"></script>
<script src="Scripts/calendar.js"></script>
<script src="app.js"></script>
<title></title>

<div ng-controller="MainController">

    <div class="calendar" ui-calendar="calOptions" ng-model="eventSources"></div>

</div>

The problem is that the configuration is ignored. the events did get in... Any idea what I'm doing wrong?

Upvotes: 1

Views: 556

Answers (1)

Mario Levrero
Mario Levrero

Reputation: 3367

I made a plunker with your code and it's working properly.

Check that you get your config properly at the directive, when it load the config:

this.getFullCalendarConfig = function(calendarSettings, uiCalendarConfig){
          var config = {};

          angular.extend(config, uiCalendarConfig);
          angular.extend(config, calendarSettings);

          angular.forEach(config, function(value,key){
            if (typeof value === 'function'){
              config[key] = wrapFunctionWithScopeApply(config[key]);
            }
          });

          return config;
      };

Upvotes: 1

Related Questions