gpt4 book ai didi

javascript - Angular ( ionic )渲染复选框中的真实值

转载 作者:行者123 更新时间:2023-11-28 05:51:21 28 4
gpt4 key购买 nike

我正在使用 ionic + parse js sdk,并且只想渲染复选框中的真实值。

以下是范围:

$scope.Diagnosed = [
{ text: "Allergies", checked: true},
{ text: "ADHD", checked: false},
{ text: "Alcohol/Drug Dependence", checked: false},
{ text: "Asthma", checked: false},
{ text: "Autism", checked: false},
{ text: "Cancer", checked: false},
{ text: "Diabetes", checked: false},
{ text: "Eating Disorder", checked: false},
{ text: "Fertility Problems", checked: false},
{ text: "Heart Disease", checked: false},
{ text: "High Cholesterol", checked: false},
{ text: "Menopause", checked: false},
{ text: "Mood Disorders (e.g., anxiety, depression)", checked: false},
{ text: "Obesity", checked: false},
{ text: "Stroke", checked: false},
{ text: "Prefer not to answer", checked: false}

];

首页上的内容如下所示:

<ion-item  ng-class="" ng-repeat="object in lines" class="item-thumbnail-left item-icon-right item-text-wrap" href="#/moresurvey/{{object.id}}">

<a><h2>{{object.visafname}}</h2></a>
<h2 >{{object.visalname}}</h2>
<p>{{object.gender}}</p>
<i class="icon ion-chevron-right icon-accessory"></i>

<ion-option-button class="button" ng-click="deleteEvent(line)">
Delete
</ion-option-button>
</ion-item>

我使用以下代码在不同页面上呈现值:

query.get(id,{
success: function(response){

var currentStart = 1
for (var i = currentStart; i < response.length; i++) {
var object = response[i];
}

$scope.Details = {
diagnosed: response.get('diagnosed'),

};
},
error: function(error){
alert("Error: " + error.code + " " + error.message);
}
});
};

我的 html 如下所示:

</ion-item class="more-list">
<ion-item class="item more-item">
<i class="icon-left ion-cash more-icon"></i>
<p class="moredetails location"> {{Details.diagnosed}}</p>
</ion-item>
</ion-item>
</ion-list>

在该页面上,数据呈现如下:

 [{"checked":true,"text":"Allergies"},{"checked":false,"text":"ADHD"},{"checked":false,"text":"Alcohol/Drug Dependence"},{"checked":false,"text":"Asthma"},{"checked":false,"text":"Autism"},{"checked":false,"text":"Cancer"},{"checked":false,"text":"Diabetes"},{"checked":false,"text":"Eating Disorder"},{"checked":false,"text":"Fertility Problems"},{"checked":false,"text":"Heart Disease"},{"checked":false,"text":"High Cholesterol"},{"checked":false,"text":"Menopause"},{"checked":false,"text":"Mood Disorders (e.g., anxiety, depression)"},{"checked":false,"text":"Obesity"},{"checked":false,"text":"Stroke"},{"checked":false,"text":"Prefer not to answer"}]

但是如何只显示已检查为 true 的值呢?

提前谢谢您..

最佳答案

您好,在您的 HTMl 中只需检查 ng-if="item.checked"的条件,因此如果为 true,则仅显示它

HTML

<ion-item ng-repeat="item in items" item="item" class="item-remove-animate">
<div class="p10" ng-if="item.checked">
<ion-checkbox ng-model="item.checked"></ion-checkbox>
<i class="icon-left ion-cash more-icon"></i>
<p class="moredetails location"> {{item.text}}</p>
</div>

关于javascript - Angular ( ionic )渲染复选框中的真实值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38045425/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com