ionlabel 和 ioncheckbox 在 ngIf 内部不起作用,在 ngFor 内部
ionlabel and ioncheckbox is not working inside inside ngIf which is inside ngFor
我正在尝试并排显示标签和输入字段
在另一种情况下,尝试并排显示复选框和标签。
我已经搜索过了,我必须看到它是离子框架问题,这是真的吗?我尝试使用 switch 和 ngcontainer 以及 div,但没有成功。
"filters_list" : [
{
title: "Group Name 1",
typeOfGroupUI: "1",
filters: [{
title: "Sub-Filter1",
typeOfUI: "1",
}, {
title: "Sub-Filter2",
typeOfUI: "1",
}, {
title: "Sub-Filter3",
typeOfUI: "1",
}, ]
}, {
title: "Group Name 2",
typeOfGroupUI: "2",
filters: [{
title: "Score",
typeOfUI: "2",
}]
}]
以上是我的json.
下面是我的.html代码
<div *ngFor="let filter of filters_list; let i=index" style="height: 100%;">
<div *ngFor="let subFilter of filter.filters; let i=index">
<div *ngIf="checkIsOtherGroup(filter) else otherGroup">
<ion-list class="inner-listview">
</ion-list>
</div>
<ng-template #otherGroup>
<div *ngIf"subFilter.typeOfUI == 1">
**<ion-label>{{subFilter.title}}</ion-label>**
</div>
</ng-template>
</div>
</div>
ionlabel 文本未显示,当我尝试使用 h2 标签打印时标签显示。
有人可以帮我解决这个问题吗?
更新
我已经更新了我的代码并把它放在这里
https://stackblitz.com/edit/ionic-ijwxbh?embed=1&file=pages/home/home.html
不知道checkIsOtherGroup(filter)
的功能是什么。
将 *ngif
更改为 *ngIf
。然后就可以看到ion-label里面的文字了。
看到这个 example.
UPDATE
将 item-content
添加到 div
元素,如下所示。
<div item-content *ngIf="subFilter.typeOfUI ==1">
<ion-label>{{subFilter.title}}</ion-label>
<ion-input type="text" value=""></ion-input>
</div>
看*ngIf
里面的表达式:
<div *ngFor="let filter of filters_list; let i=index" style="height: 100%;">
<div *ngFor="let subFilter of filter.filters; let i=index">
̶<̶d̶i̶v̶ ̶*̶n̶g̶I̶f̶=̶"̶c̶h̶e̶c̶k̶I̶s̶O̶t̶h̶e̶r̶G̶r̶o̶u̶p̶(̶f̶i̶l̶t̶e̶r̶)̶ ̶ ̶e̶l̶s̶e̶ ̶o̶t̶h̶e̶r̶G̶r̶o̶u̶p̶"̶>̶
<div *ngIf="checkIsOtherGroup(filter) || otherGroup">
<ion-list class="inner-listview">
</ion-list>
</div>
<ng-template #otherGroup>
̶<̶d̶i̶v̶ ̶*̶n̶g̶i̶f̶"̶s̶u̶b̶F̶i̶l̶t̶e̶r̶.̶t̶y̶p̶e̶O̶f̶U̶I̶ ̶=̶=̶ ̶1̶"̶>̶
<div *ngIf="subFilter.typeOfUI == 1">
**<ion-label>{{subFilter.title}}</ion-label>**
</div>
</ng-template>
</div>
</div>
我正在尝试并排显示标签和输入字段 在另一种情况下,尝试并排显示复选框和标签。
我已经搜索过了,我必须看到它是离子框架问题,这是真的吗?我尝试使用 switch 和 ngcontainer 以及 div,但没有成功。
"filters_list" : [
{
title: "Group Name 1",
typeOfGroupUI: "1",
filters: [{
title: "Sub-Filter1",
typeOfUI: "1",
}, {
title: "Sub-Filter2",
typeOfUI: "1",
}, {
title: "Sub-Filter3",
typeOfUI: "1",
}, ]
}, {
title: "Group Name 2",
typeOfGroupUI: "2",
filters: [{
title: "Score",
typeOfUI: "2",
}]
}]
以上是我的json.
下面是我的.html代码
<div *ngFor="let filter of filters_list; let i=index" style="height: 100%;">
<div *ngFor="let subFilter of filter.filters; let i=index">
<div *ngIf="checkIsOtherGroup(filter) else otherGroup">
<ion-list class="inner-listview">
</ion-list>
</div>
<ng-template #otherGroup>
<div *ngIf"subFilter.typeOfUI == 1">
**<ion-label>{{subFilter.title}}</ion-label>**
</div>
</ng-template>
</div>
</div>
ionlabel 文本未显示,当我尝试使用 h2 标签打印时标签显示。
有人可以帮我解决这个问题吗?
更新
我已经更新了我的代码并把它放在这里 https://stackblitz.com/edit/ionic-ijwxbh?embed=1&file=pages/home/home.html
不知道checkIsOtherGroup(filter)
的功能是什么。
将 *ngif
更改为 *ngIf
。然后就可以看到ion-label里面的文字了。
看到这个 example.
UPDATE
将 item-content
添加到 div
元素,如下所示。
<div item-content *ngIf="subFilter.typeOfUI ==1">
<ion-label>{{subFilter.title}}</ion-label>
<ion-input type="text" value=""></ion-input>
</div>
看*ngIf
里面的表达式:
<div *ngFor="let filter of filters_list; let i=index" style="height: 100%;">
<div *ngFor="let subFilter of filter.filters; let i=index">
̶<̶d̶i̶v̶ ̶*̶n̶g̶I̶f̶=̶"̶c̶h̶e̶c̶k̶I̶s̶O̶t̶h̶e̶r̶G̶r̶o̶u̶p̶(̶f̶i̶l̶t̶e̶r̶)̶ ̶ ̶e̶l̶s̶e̶ ̶o̶t̶h̶e̶r̶G̶r̶o̶u̶p̶"̶>̶
<div *ngIf="checkIsOtherGroup(filter) || otherGroup">
<ion-list class="inner-listview">
</ion-list>
</div>
<ng-template #otherGroup>
̶<̶d̶i̶v̶ ̶*̶n̶g̶i̶f̶"̶s̶u̶b̶F̶i̶l̶t̶e̶r̶.̶t̶y̶p̶e̶O̶f̶U̶I̶ ̶=̶=̶ ̶1̶"̶>̶
<div *ngIf="subFilter.typeOfUI == 1">
**<ion-label>{{subFilter.title}}</ion-label>**
</div>
</ng-template>
</div>
</div>