1

I'm using Angular 5 and mattlewis92/angular-calendar. when events are defined manually in code i have no issue. However when i query my database and try to bind the result to the calender, there seem to be som kind of sync issue on first load. when i do an 'onlick', everything gets up to date.

It seems that the calendar is not that reactive. My guess is that it the observable returns the objects to late.

please se the gif that illustrates the problem http://gph.is/2ELyvDs

Thanks

K N
  • 279
  • 5
  • 22

2 Answers2

1

I commented out changeDetection and everything seems to work fine now.

@Component({
   selector: 'mwl-demo-component',
   // changeDetection: ChangeDetectionStrategy.OnPush,
   templateUrl: 'bookingcalendar.component.html'
})
K N
  • 279
  • 5
  • 22
  • 1
    I have a similar problem, my data is not shown until I change my view to week or day. If I change the route and return, I have to do the same to show them, could you share your code to guide me? – nicogaldo Apr 04 '18 at 19:03
  • I have the same problem and comment changeDetection didn1t solve my problem. My complete code and a good explanation is here: https://stackoverflow.com/questions/55365513/calendar-dont-show-events-in-first-load-only-after-trigger-any-element-in-wind – Adriano Frota Mar 27 '19 at 20:23
0

I have seen a few answers for this. Adding encapsulation: ViewEncapsulation.None, also, adding this.refresh.next, but these weren't working for me. However, what I realised was that it was taking a bit of time for the events to be retrieved from a database so this.refresh.next worked after a timeout.

   setTimeout(() => 
{
this.refresh.next();

},
900);

}

Vernon007
  • 190
  • 1
  • 15