我正在使用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的值?
提前谢谢..
答案 0 :(得分:0)
您好在HTMl中检查ng-if =&#34; item.checked&#34;所以,如果是真的,它只会显示
<强> 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>