ngClass 仅在前三行中应用一个类,并将在最后一行中应用所有类:
<ion-list id="wifiList-list2">
<ion-item color="none" id="wifiList-list-item1" *ngFor="let wifi of wifi_list" on-click="goToSSID(wifi)">
<!-- <ion-icon name="wifi" item-left></ion-icon> -->
<div
[ngClass]="{
'signal-bars mt1 sizing-box good four-bars' : (wifi.level) < '0' && (wifi.level) > '-60',
'signal-bars mt1 sizing-box four-bars bad one-bar' : (wifi.level) <= '-70' && (wifi.level) > '-90',
'signal-bars mt1 sizing-box four-bars bad two-bars' : (wifi.level) <= '-67' && (wifi.level) > '-70',
'signal-bars mt1 sizing-box four-bars ok three-bars' : (wifi.level) <= '-60' && (wifi.level) > '-67'
}"
>
<div class="first-bar bar"></div>
<div class="second-bar bar"></div>
<div class="third-bar bar"></div>
<div class="fourth-bar bar"></div>
</div>
</ion-item>
</ion-list>
在下面的屏幕快照中,任何具有-35值的 wifi.level 都将仅应用于一类“好”,而跳过其余的。值-63 的所有 wifi.level都将适用于所有类别:“信号栏mt1大小调整框四栏好的三栏”
与上面的截图相同, wifi.level = -73 仅适用于“差”类。
删除' '
和( )
时,我得到相同的结果:
<ion-list id="wifiList-list2">
<ion-item color="none" id="wifiList-list-item1" *ngFor="let wifi of wifi_list" on-click="goToSSID(wifi)">
<!-- <ion-icon name="wifi" item-left></ion-icon> -->
<div
[ngClass]="{
'signal-bars mt1 sizing-box good four-bars' : wifi.level < 0 && wifi.level > -60,
'signal-bars mt1 sizing-box four-bars bad one-bar' : wifi.level <= -70 && wifi.level > -90,
'signal-bars mt1 sizing-box four-bars bad two-bars' : wifi.level <= -67 && wifi.level > -70,
'signal-bars mt1 sizing-box four-bars ok three-bars' : wifi.level <= -60 && wifi.level > -67
}"
>
<div class="first-bar bar"></div>
<div class="second-bar bar"></div>
<div class="third-bar bar"></div>
<div class="fourth-bar bar"></div>
</div>
</ion-item>
</ion-list>
答案 0 :(得分:-1)
用没有wifi.level
的数字比较''
的值。
让我知道这是否对您有用。