[英]ionlabel and ioncheckbox is not working inside inside ngIf which is inside ngFor
I am trying to display label and input field side by side and in another case trying to display checkbox and label side by side. 我试图并排显示标签和输入字段,在另一种情况下试图并排显示复选框和标签。
I have searched, I've got to see it's the ionic framework issue, is this true? 我已经搜索过,我必须看到这是离子骨架问题,这是真的吗? And I tried with switch and ngcontainer and div's but it did not work out.
我尝试使用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",
}]
}]
The above is my json. 上面是我的json。
The below is my .html code 以下是我的.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>
The ionlabel text is not getting displayed, when I tried to print with h2 tag then the label is getting displayed. ionlabel文本未显示,当我尝试使用h2标签进行打印时,该标签正在显示。
Can someone help me out how to solve the problem? 有人可以帮我解决问题吗?
UPDATE 更新
I have updated my code and placed it here https://stackblitz.com/edit/ionic-ijwxbh?embed=1&file=pages/home/home.html 我已经更新了代码并将其放在这里https://stackblitz.com/edit/ionic-ijwxbh?embed=1&file=pages/home/home.html
Don't know what is the functionality of checkIsOtherGroup(filter)
. 不知道
checkIsOtherGroup(filter)
的功能是什么。 change *ngif
to *ngIf
. 将
*ngif
更改为*ngIf
。 Then you can see the text inside ion-label. 然后,您可以看到离子标签内的文本。 See this example .
请参阅此示例 。
UPDATE
更新
Add item-content
to the div
element as follows. 将
item-content
添加到div
元素,如下所示。
<div item-content *ngIf="subFilter.typeOfUI ==1">
<ion-label>{{subFilter.title}}</ion-label>
<ion-input type="text" value=""></ion-input>
</div>
Look at the expression inside the *ngIf
: 查看
*ngIf
内的*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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.