je l'élément suivant dans le fichier html:Comment lier "readonly" dans un élément personnalisé dans Aurelia?
<require from="_controls/time-slot-slider"></require>
<time-slot-slider id="zeitraum" min="0" max="24" length="4" value="4"
value.two-way="functionConfig.startTime" if.bind="functionConfig.isAutomatic === true"
readonly.bind="!mayFunctionTestEditTime"></time-slot-slider>
élément personnalisé est ici (tranche de temps slider.html):
<template class="range-slider time-slot">
<div>${duration}</div>
<input type="range" min.bind="min" max.bind="maxStart" step.bind="step" value.bind="value">
</template>
et de temps sous-slider.ts:
import { bindable, customElement } from 'aurelia-templating'
import moment from 'moment/moment'
import Moment = moment.Moment
@customElement('time-slot-slider')
export class TimeSlotSlider {
@bindable public min: number = 0.0
@bindable public max: number = 24.0
@bindable public step: number = 0.5
@bindable public value: number = 0.0
@bindable public length: number = 4.0
public get maxStart(): number {
return this.max - this.length
}
public get from(): Moment {
return TimeSlotSlider.numberToMoment(this.value)
}
....
Mais readonly.bind ne fonctionne pas. J'ai essayé de lier readonly par
@bindable readOnly: boolean
mais je n'ai eu aucun succès. Comment puis-je le réparer?
Je l'ai fait. Mais je reçois cet avertissement: ne peut pas trouver 'readonly' dans le type 'TimeSlotSlider' – Sohrab
Vous avez écrit 'readOnly' au lieu de' readonly'. Notez le 'O' majuscule. Changez readOnly en readonly dans votre viewmodel ou readonly.bind en read-only.bind dans le code HTML où vous utilisez ce composant. –
Merci beaucoup soooooooo – Sohrab