我可以动态地将css类设置为typescript函数的返回值吗?

时间:2017-10-22 06:20:35

标签: javascript html css class typescript

我想根据函数调用的返回值来确定css类,如下所示:

<ion-col style="getBooking(950)">
   <div (tap)="this.makeOrRemoveBooking(950)">09:30</div>
</ion-col>
<ion-col style="this.getBooking(1000)">
    <div (tap)="this.makeOrRemoveBooking(950)">10:00</div>
</ion-col>
<ion-col style="this.getBooking(1050)">
    <div (tap)="this.makeOrRemoveBooking(950)">10:30</div>
</ion-col>

这是功能:

    getBooking(time: number) {
    for (const book of this.localListOfBookings) {
        if (book.startTime <= time && time < book.endTime) {
            if (book.bookedByName == this.currentUserName) {
                return "yourRoom"
            } else {
                return "available"
            }
            // return book.bookedByName
        }
    }
}

0 个答案:

没有答案