tharindu
tharindu

Reputation: 523

Displaying only the title in the specific date of the calendar

I use fullcalendar in angularjs as follows to display some event values in the calendar

It displays the values correctly.

<html>
   <head>
   <link rel="stylesheet" href="../fullcalendar- 
   4.1.0/packages/core/main.css"></script>
   <link rel="stylesheet" href="../fullcalendar- 
   4.1.0/packages/daygrid/main.css"></script>
   <link rel="stylesheet" href="../fullcalendar- 
   4.1.0/packages/list/main.css"></script>
   <link rel="stylesheet" href="../fullcalendar- 
  4.1.0/packages/timegrid/main.css"></script>
  <script type="text/javascript" src="../fullcalendar- 
    4.1.0/packages/core/main.js"></script>
    <script type="text/javascript" src="../fullcalendar- 
    4.1.0/packages/daygrid/main.js"></script>
    <script type="text/javascript" src="../fullcalendar- 
    4.1.0/packages/timegrid/main.js"></script>
    <script type="text/javascript" src="../fullcalendar- 
   4.1.0/packages/list/main.js"></script>
   </head>
   <script>
    $scope.event = {events: [{
            title:'test1',
            start: '2019-05-05 08:00',
            end: '2019-05-10 08:00'
          },
          {
            title:'test2',
            start: '2019-05-05 12:00'
        }]};
    var calendarEl = document.getElementById('calendar');

        var calendar = new FullCalendar.Calendar(calendarEl, {
            events: $scope.event.events,
            plugins: [ 'dayGrid','timeGrid','list' ],
            header: {
                      left: 'prev,next today',
                      center: 'title',
                      right: 'dayGridMonth,dayGridWeek,timeGridDay'
                    }
        });
        calendar.render();
    });
   </script>
   <body ng-app="myApp" ng-controller="myController">
   <div id="calendar" ng-model="eventSources"></div>    
   </body>
   </html>

Although I have declared a title in the above it always appends the time with a or p accordingly on the specific date. How can I only display the title in the calendar ?

Upvotes: 0

Views: 373

Answers (2)

tharindu
tharindu

Reputation: 523

If we want to prevent appending the time to the title we need to define the start and end time without declaring the time as below.

$scope.event = {events: [{
            title:'test1',
            start: '2019-05-05',
            end: '2019-05-10'
          },
          {
            title:'test2',
            start: '2019-05-05'
        }]};

Please note that I haven't uploaded the whole code but have updated the changed code only. Rest of the code remains the same.

Upvotes: 0

Akber Iqbal
Akber Iqbal

Reputation: 15041

if there is a time specified, it will be displayed as a (for AM) or p (for PM); for all-day events, you can skip entering a time at all... you can check the following code below:

UPDATE: You can use CSS to remove the time also - this way there will be no difference between all-day events and events with a fixed start and/or end times.

angular.module('myApp', [])
  .controller('myController', function($scope) {
    $scope.event = {
      events: [{
          title: 'test1',
          start: '2019-05-05',
          end: '2019-05-10'
        },
        {
          title: 'test2',
          start: '2019-05-05'
        },
        {
          title: 'test3',
          start: '2019-05-13 15:00',
          end: '2019-05-15 11:30'
        },
        {
          title: 'test4',
          start: '2019-05-26 10:00',
          end: '2019-05-28 13:30'
        }
      ]
    };
    var calendarEl = document.getElementById('calendar');

    var calendar = new FullCalendar.Calendar(calendarEl, {
      events: $scope.event.events,
      plugins: ['dayGrid', 'timeGrid', 'list'],
      header: {
        left: 'prev,next today',
        center: 'title',
        right: 'dayGridMonth,dayGridWeek,timeGridDay'
      }
    });
    calendar.render();
  });
html,
body {
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
  font-size: 14px;
}

#calendar {
  max-width: 900px;
  margin: 40px auto;
}

.fc-day-grid-event .fc-time {
  display: none;
}
<link href='https://fullcalendar.io/assets/demo-to-codepen.css' rel='stylesheet' />
<link href='https://fullcalendar.io/releases/core/4.1.0/main.min.css' rel='stylesheet' />
<link href='https://fullcalendar.io/releases/daygrid/4.1.0/main.min.css' rel='stylesheet' />
<link href='https://fullcalendar.io/releases/timegrid/4.1.0/main.min.css' rel='stylesheet' />
<script src='https://fullcalendar.io/assets/demo-to-codepen.js'></script>
<script src='https://fullcalendar.io/releases/core/4.1.0/main.min.js'></script>
<script src='https://fullcalendar.io/releases/interaction/4.1.0/main.min.js'></script>
<script src='https://fullcalendar.io/releases/daygrid/4.1.0/main.min.js'></script>
<script src='https://fullcalendar.io/releases/timegrid/4.1.0/main.min.js'></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>

<body ng-app="myApp" ng-controller="myController">
  <div id="calendar" ng-model="eventSources"></div>
</body>

Upvotes: 1

Related Questions