twinssbc / Ionic2-Calendar

A calendar component based on Ionic framework
https://ionic-calendar-demo.stackblitz.io
MIT License
387 stars 196 forks source link

how to personalize ionic2-calendar #478

Open sdore2021 opened 4 years ago

sdore2021 commented 4 years ago

hello. someone can help me. I want to personnalize my view event detail. so i have to add un new component in my file.ts and call it in my html file. but i don't kwon how to use this TemplateRef:

monthviewEventDetailTemplate: TemplateRef

myfile.ts

@Component({ selector: 'page-agenda', templateUrl: 'agenda.html', }) //#monthviewDefaultEventDetailTemplate --> dans le template

@Component({ selector: 'my-calendar', template: `<template #monthviewDefaultEventDetailTemplate let-showEventDetail="showEventDetail" let-selectedDate="selectedDate" let-noEventsLabel="noEventsLabel"> <ion-list class="event-detail-container" has-bouncing="false" ngIf="showEventDetail" overflow-scroll="false"> <ion-item ngFor="let event of selectedDate?.events" (click)="eventSelected(event)"> <span *ngIf="!event.allDay" class="monthview-eventdetail-timecolumn">{{event.startTime|date: 'HH:mm'}}

              {{event.endTime|date: 'HH:mm'}}
          </span>
      <span *ngIf="event.allDay" class="monthview-eventdetail-timecolumn">All day</span>
      <span class="event-detail">  |  {{event.title}}</span>
  </ion-item>
  <ion-item *ngIf="selectedDate?.events.length==0">
      <div class="no-events-label">{{noEventsLabel}}</div>
  </ion-item>

, styles: [.event-detail-container { border-top: 2px darkgrey solid; } .no-events-label { font-weight: bold; color: darkgrey; text-align: center; } .event-detail { cursor: pointer; white-space: nowrap; text-overflow: ellipsis; }`] })

sdore2021 commented 4 years ago

how to use this: monthviewEventDetailTemplate: TemplateRef

twinssbc commented 4 years ago

@sdore2021 You need to put the template code in HTML file like below:

    <ng-template #template let-showEventDetail="showEventDetail" let-selectedDate="selectedDate" let-noEventsLabel="noEventsLabel">
    ... 
    </ng-template>

    <calendar ... [monthviewEventDetailTemplate]="template"></calendar>
sdore2021 commented 4 years ago

Thanks for yours answers.

so i need to create a new component in ionic (e.g : ionic g component calendar) and insert template code in calendar.html like this:

and add this option in my agenda.html but i don't know how to use this component in my agenda.ts code because the onligne documentation said that my problem is how to put this argument {"showEventDetail', "seletedDate ", "noEventLabel "} and Template because they are no example using in website internet.

Thank you.

De: "twinssbc" notifications@github.com À: "twinssbc/Ionic2-Calendar" Ionic2-Calendar@noreply.github.com Cc: "Samouka Dore" samouka.dore@insa-cvl.fr, "Mention" mention@noreply.github.com Envoyé: Jeudi 21 Novembre 2019 15:05:24 Objet: Re: [twinssbc/Ionic2-Calendar] how to personalize ionic2-calendar (#478)

[ https://github.com/sdore2021 | @sdore2021 ] You need to put the template code in HTML file like below: <ng-template #template let-showEventDetail="showEventDetail" let-selectedDate="selectedDate" let-noEventsLabel="noEventsLabel"> ...

<calendar ... [monthviewEventDetailTemplate]="template"></calendar> 

— You are receiving this because you were mentioned. Reply to this email directly, [ https://github.com/twinssbc/Ionic2-Calendar/issues/478?email_source=notifications&email_token=ANBKNDHYHTIFLHOHGCSXGLDQU2ISJA5CNFSM4JQA5KM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEE2KRNA#issuecomment-557099188 | view it on GitHub ] , or [ https://github.com/notifications/unsubscribe-auth/ANBKNDE7MLJVBS5HZ33S243QU2ISJANCNFSM4JQA5KMQ | unsubscribe ] .

twinssbc commented 4 years ago

@sdore2021

You don't need to specify the showEventDetail, selectedDate or noEventsLabel by yourself. It is passed in automatically, you just need to use it.

This link may give you some idea. https://angular.io/api/common/NgTemplateOutlet#description

sdore2021 commented 4 years ago

okay thanks. I think I need to learn angular before continue this project because i have not understood yet how to use this in my file.ts

thank you for all.

De: "twinssbc" notifications@github.com À: "twinssbc/Ionic2-Calendar" Ionic2-Calendar@noreply.github.com Cc: "Samouka Dore" samouka.dore@insa-cvl.fr, "Mention" mention@noreply.github.com Envoyé: Samedi 23 Novembre 2019 07:24:26 Objet: Re: [twinssbc/Ionic2-Calendar] how to personalize ionic2-calendar (#478)

[ https://github.com/sdore2021 | @sdore2021 ]

You don't need to specify the showEventDetail, selectedDate or noEventsLabel by yourself. It is passed in automatically, you just need to use it.

This link may give you some idea. [ https://angular.io/api/common/NgTemplateOutlet#description | https://angular.io/api/common/NgTemplateOutlet#description ]

— You are receiving this because you were mentioned. Reply to this email directly, [ https://github.com/twinssbc/Ionic2-Calendar/issues/478?email_source=notifications&email_token=ANBKNDFTRA6DBJTNRZZD4J3QVDEBVA5CNFSM4JQA5KM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEE7OXKI#issuecomment-557771689 | view it on GitHub ] , or [ https://github.com/notifications/unsubscribe-auth/ANBKNDFXZ4XOXOJ3FNA2W7TQVDEBVANCNFSM4JQA5KMQ | unsubscribe ] .

sdore2021 commented 4 years ago

thanks. my problem is solved.