Commit 5a811422 by Chao Sun

添加selected

parent e2a5c230
......@@ -94,6 +94,15 @@ export class AgeComponent implements OnInit {
this.isShow = true;
this.curQues = question;
this.curQuesIndex = idx;
console.log(question)
for(let i=0;i<question['options'].length;i++){
if(question.optionName == question['options'][i].optionName){
question['options'][i]['selected'] = true
}else{
question['options'][i]['selected'] = false
}
}
// if( )
}
closeToast() {
......
......@@ -3,7 +3,7 @@
<div class="questionTitle">{{ curPageData?.pageName }}</div>
<ul class="option_item" style="margin-top: 20%;">
<li *ngFor="let options of curPageData?.questions[0]['options']" (click)="selectedFamily(options)">
<img [ngClass]="{ selected: selectedOptionId == options.optionId }"
<img [ngClass]="{ selected: options['selected'] }"
src="assets/images/icon{{ options.optionId }}.png"
alt="{{ options.optionName }}"/>
<span>{{ options.optionName }}</span>
......
......@@ -32,7 +32,14 @@ export class FamilyComponent implements OnInit {
// 选择家庭结构
selectedFamily(option) {
this.selectedOptionId = option.optionId;
option.selected = true;
const options = this.curPageData['questions'][0]['options']
for (let i = 0; i < options.length; i++) {
if (option['optionId'] == options[i]['optionId']) {
options[i]['selected'] = true;
} else {
options[i]['selected'] = false;
}
}
this.pageAnswers = {
pageId: this.curPageData['pageId'],
questions: [{
......@@ -42,7 +49,7 @@ export class FamilyComponent implements OnInit {
}],
};
this.commonService.addAnswer(this.pageAnswers);
// console.log(this.pageAnswers)
console.log(this.pageAnswers)
}
// 下一步
......
......@@ -115,6 +115,7 @@ export class LiveComponent implements OnInit {
this.nextBtn = false;
}
// console.log(this.pageAnswers);
console.log(this.commonService.todos)
}
next() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment