nekken / ng2-fullcalendar

95 stars 47 forks source link

change option object dynamically from angular 2 #26

Closed almgwary closed 7 years ago

almgwary commented 7 years ago

@nekken i frigged it out i will fork and fix it just i will handle on options change from docs https://fullcalendar.io/docs/utilities/dynamic_options/ some of them need specific function call

alan345 commented 7 years ago

hey @almgwary , I got the same question, how can we change option object dynamically? Your link is not in angular2.. thanks for you help

almgwary commented 7 years ago

hey @alan345 sorry for late . i made it work by the following code

import :

import {Options} from "fullcalendar";
import * as $ from 'jquery';

add change function :

change(changes: any) {

      $('angular2-fullcalendar').fullCalendar('changeView',changes.options.currentValue.defaultView);
      let locale = $('angular2-fullcalendar').fullCalendar('option', 'locale');

  }

 /**
   *
   * @param event
   * @param isStick: needed because event object not have stick value, we need to set it natively
   *
   * renderEvent 1.3
   * Renders a new event on the calendar.
   * .fullCalendar( 'renderEvent', event [, stick ] )
   * event must be an Event Object with a title and start at the very least.
   * Normally, the event will disappear once the calendar refetches its event sources (example: when prev/next is clicked). However, specifying stick as true will cause the event to be permanently fixed to the calendar.
   */

  renderEvent(event:any,isStick:boolean){
    if(isStick == true){
      event.stick = true ;
    }
    // console.log('FullCalendar renderEvent',{event});
    $('angular2-fullcalendar').fullCalendar('renderEvent',event);
  }