FullCalendar

FullCalendarAn event calendar based on the FullCalendar library.

FullCalendar - 图1

Documentation

Import

  1. import {FullCalendarModule} from 'primeng/fullcalendar';
  2.  

Getting Started

FullCalendar is a wrapper around on FullCalendar 4.0.1+ so fullcalendar core needs to be included in your project. For a complete documentation and samples please refer to the fullcalendar website.

  1. npm install @fullcalendar/core --save
  2.  

FullCalendar is plugin based so install the plugins you require and define them with the options property.

  1. npm install @fullcalendar/daygrid --save
  2. npm install @fullcalendar/timegrid --save
  3. npm install @fullcalendar/interaction --save
  4.  

Events should be an array and defined using the events property.

  1. <p-fullCalendar [events]="events"></p-fullCalendar>
  2.  
  1. export class MyModel {
  2. events: any[];
  3. ngOnInit() {
  4. this.events = [
  5. {
  6. "title": "All Day Event",
  7. "start": "2016-01-01"
  8. },
  9. {
  10. "title": "Long Event",
  11. "start": "2016-01-07",
  12. "end": "2016-01-10"
  13. },
  14. {
  15. "title": "Repeating Event",
  16. "start": "2016-01-09T16:00:00"
  17. },
  18. {
  19. "title": "Repeating Event",
  20. "start": "2016-01-16T16:00:00"
  21. },
  22. {
  23. "title": "Conference",
  24. "start": "2016-01-11",
  25. "end": "2016-01-13"
  26. }
  27. ];
  28. }
  29. }
  30.  

In a real application, it is likely to populate the events by making a service call, when the events are updated, the component will detect the change and render them.

  1. @Injectable()
  2. export class EventService {
  3. constructor(private http: Http) {}
  4. getEvents() {
  5. return this.http.get('showcase/resources/data/calendarevents.json')
  6. .toPromise()
  7. .then(res => <any[]> res.json().data)
  8. .then(data => { return data; });
  9. }
  10. }
  11.  
  1. export class MyModel {
  2. events: any[];
  3. ngOnInit() {
  4. this.eventService.getEvents().then(events => {this.events = events;});
  5. }
  6. }
  7.  

Options

FullCalendar has a long list of customization parameters that are defined with the options property. Example below customizes the header property.

  1. import dayGridPlugin from '@fullcalendar/daygrid';
  2. import timeGridPlugin from '@fullcalendar/timegrid';
  3. import interactionPlugin from '@fullcalendar/interaction';
  4. export class FullCalendarDemo implements OnInit {
  5. events: any[];
  6. options: any;
  7. constructor(private eventService: EventService) { }
  8. ngOnInit() {
  9. this.eventService.getEvents().then(events => {this.events = events;});
  10. this.options = {
  11. plugins: [dayGridPlugin, timeGridPlugin, interactionPlugin],
  12. defaultDate: '2017-02-01',
  13. header: {
  14. left: 'prev,next',
  15. center: 'title',
  16. right: 'month,agendaWeek,agendaDay'
  17. }
  18. {;
  19. }
  20. }
  21.  
  1. <p-fullCalendar [events]="events" [options]="options"></p-fullCalendar>
  2.  

Change Detection

Updates to the events or options are reflected to the UI whenever a change occurs. An important note here is that UI update only happens whenever a new instance is created on these twp properties. Simply changing the events array without creating a new instance of the array or updating a property inside options will have no effect.

  1. update() {
  2. //incorrect
  3. this.events.push({
  4. "title": "Conference",
  5. "start": "2016-01-11",
  6. "end": "2016-01-13"
  7. });
  8. //correct
  9. this.events = [...this.events, {
  10. "title": "Conference",
  11. "start": "2016-01-11",
  12. "end": "2016-01-13"
  13. }];
  14. //incorrect
  15. this.options.weekends = false;
  16. //correct
  17. this.options = {...this.options, {weekends: false}};
  18. }
  19.  

Callbacks

Callbacks of the FullCalendar are also defined with the options property.

  1. this.options = {
  2. plugins: [dayGridPlugin, timeGridPlugin, interactionPlugin],
  3. header: {
  4. left: 'prev,next',
  5. center: 'title',
  6. right: 'month,agendaWeek,agendaDay'
  7. },
  8. dateClick: (e) => {
  9. //handle date click
  10. }
  11. }
  12.  

Methods

Methods of the underlying calendar instance is accessible using the reference of the components getCalendar() API.

  1. <p-fullCalendar #fc [events]="events" [options]="options"></p-fullCalendar>
  2.  
  1. @ViewChild('fc') fc: FullCalendar;
  2. gotoDate(date: Date) {
  3. this.fc.getCalendar().gotoDate(date);
  4. }
  5.  

Properties

NameTypeDescription
eventsarrayAn array of events to display.
optionsObjectA configuration object to define properties of FullCalendar.

Dependencies

FullCalendar.

Source

View on GitHub

  1. <p-fullCalendar [events]="events" [options]="options"></p-fullCalendar>
  2.  
  1. import dayGridPlugin from '@fullcalendar/daygrid';
  2. import timeGridPlugin from '@fullcalendar/timegrid';
  3. import interactionPlugin from '@fullcalendar/interaction';
  4. export class FullCalendarDemo implements OnInit {
  5. events: any[];
  6. options: any;
  7. constructor(private eventService: EventService) { }
  8. ngOnInit() {
  9. this.eventService.getEvents().then(events => {this.events = events;});
  10. this.options = {
  11. plugins: [dayGridPlugin, timeGridPlugin, interactionPlugin],
  12. defaultDate: '2017-02-01',
  13. header: {
  14. left: 'prev,next',
  15. center: 'title',
  16. right: 'month,agendaWeek,agendaDay'
  17. },
  18. editable: true
  19. };
  20. }
  21. }
  22.  
  1. @Injectable()
  2. export class EventService {
  3. constructor(private http: Http) {}
  4. getEvents() {
  5. return this.http.get('showcase/resources/data/calendarevents.json')
  6. .toPromise()
  7. .then(res => <any[]> res.json().data)
  8. .then(data => { return data; });
  9. }
  10. }
  11.  
  • 书签
  • 添加书签 移除书签
  • Get Started
  • Input
    • InputGroup
    • AutoComplete
    • Calendar
    • Checkbox
    • Chips
    • ColorPicker
    • Dropdown
    • Editor
    • KeyFilter
    • InputSwitch
    • InputText
    • InputTextArea
    • Listbox
    • Mask
    • MultiSelect
    • Password
    • RadioButton
    • Rating
    • Slider
    • Spinner
    • SelectButton
    • ToggleButton
    • TriCheckbox
  • Button
    • Button
    • SplitButton
  • Data
    • Carousel
    • DataView
    • FullCalendar
    • Org Chart
    • OrderList
    • GMap
    • Paginator
    • PickList
    • Table
    • Tree
    • TreeTable
    • VirtualScroller
  • Panel
    • Accordion
    • Card
    • Fieldset
    • Panel
    • ScrollPanel
    • FlexGrid
    • Grid
    • TabView
    • Toolbar
  • Overlay
    • ConfirmDialog
    • Dialog
    • DynamicDialog
    • Lightbox
    • Sidebar
    • OverlayPanel
    • Tooltip
  • File
    • Upload
  • Menu
    • MenuModel
    • Breadcrumb
    • ContextMenu
    • MegaMenu
    • Menu
    • Menubar
    • PanelMenu
    • SlideMenu
    • Steps
    • TabMenu
    • TieredMenu
  • Charts
    • ChartModel
    • Bar
    • Doughnut
    • Line
    • PolarArea
    • Pie
    • Radar
  • Messages
    • Messages
    • Toast
  • Multimedia
    • Galleria
  • DragDrop
    • Drag&Drop
  • Misc
    • Responsive
    • RTL
    • Defer
    • BlockUI
    • Captcha
    • Inplace
    • Validation
    • ProgressBar
    • ProgressSpinner
    • CodeHighlighter
    • Terminal
暂无相关搜索结果!

    资讯网徐州 制作网站网站建设服务流程姓高起名有寓意的如何营销seo服装设计学校网站老师来了叫我哦父亲姓高母亲姓张起名女婴起名周公解梦 2345永城市二手车市场孩子姓朱起名字胡姓起名大全四个字男孩网站建设宗旨烧烤起哪个名字即将到来任务怎么做女人起男人的名字seo关键词优化怎么收费推广营销打算通讯服务行业公司起名网站建设好用对网站提出的优化建议广州网站制作公司哪家好芳华百度云十大经典女主重生小说起名餐饮商铺怎样破解梦小宝宝起名大全2020年seo网站优化解决方案bt之家bt电影天堂seo工程师要学什么少年生前被连续抽血16次?多部门介入两大学生合买彩票中奖一人不认账让美丽中国“从细节出发”淀粉肠小王子日销售额涨超10倍高中生被打伤下体休学 邯郸通报单亲妈妈陷入热恋 14岁儿子报警何赛飞追着代拍打雅江山火三名扑火人员牺牲系谣言张家界的山上“长”满了韩国人?男孩8年未见母亲被告知被遗忘中国拥有亿元资产的家庭达13.3万户19岁小伙救下5人后溺亡 多方发声315晚会后胖东来又人满为患了张立群任西安交通大学校长“重生之我在北大当嫡校长”男子被猫抓伤后确诊“猫抓病”测试车高速逃费 小米:已补缴周杰伦一审败诉网易网友洛杉矶偶遇贾玲今日春分倪萍分享减重40斤方法七年后宇文玥被薅头发捞上岸许家印被限制高消费萧美琴窜访捷克 外交部回应联合利华开始重组专访95后高颜值猪保姆胖东来员工每周单休无小长假男子被流浪猫绊倒 投喂者赔24万小米汽车超级工厂正式揭幕黑马情侣提车了西双版纳热带植物园回应蜉蝣大爆发当地回应沈阳致3死车祸车主疑毒驾恒大被罚41.75亿到底怎么缴妈妈回应孩子在校撞护栏坠楼外国人感慨凌晨的中国很安全杨倩无缘巴黎奥运校方回应护栏损坏小学生课间坠楼房客欠租失踪 房东直发愁专家建议不必谈骨泥色变王树国卸任西安交大校长 师生送别手机成瘾是影响睡眠质量重要因素国产伟哥去年销售近13亿阿根廷将发行1万与2万面值的纸币兔狲“狲大娘”因病死亡遭遇山火的松茸之乡“开封王婆”爆火:促成四五十对奥巴马现身唐宁街 黑色着装引猜测考生莫言也上北大硕士复试名单了德国打算提及普京时仅用姓名天水麻辣烫把捣辣椒大爷累坏了

    资讯网 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化