Hey Guys!
In my APP I am trying to show a list with Checkboxes and a label, and i am reading the data out of a database so that i know which checkboxes should be checked and which not.
I am reading them correct out of the DB but it deos not show up correct in the APP…
I am calling this method in my Constructor:
var test is just for testing
getQuestions(){
this.allquestions = [];
var getFeedback = new XMLHttpRequest(); // a new request
getFeedback.open("GET","http://api/question" ,false);
getFeedback.send(null);
var newdata = JSON.parse(getFeedback.responseText);
for(var i = 0; i < newdata.data.length; i++){
var test = false;
if(i % 2 == 0){
test = true;
}
this.allquestions.push({
QuestionID: newdata.data[i].QuestionID,
questiontext: newdata.data[i].questiontext,
value: test
});
console.log(test);
}
}
This is the code in my HTML:
<ion-item *ngFor="let item of allquestions">
<ion-label text-wrap>{{item.value}}</ion-label>
<ion-checkbox name="check" [(ngModel)]="item.value" name="neededCheckboxName"></ion-checkbox>
</ion-item>
At the moment it looks like this:
So as you can see the true values arent checked, but if i am filling the value with true only values it shows up correct:
Does anybody know a solution for this?