Commit 5a811422 by Chao Sun

添加selected

parent e2a5c230
...@@ -94,6 +94,15 @@ export class AgeComponent implements OnInit { ...@@ -94,6 +94,15 @@ export class AgeComponent implements OnInit {
this.isShow = true; this.isShow = true;
this.curQues = question; this.curQues = question;
this.curQuesIndex = idx; 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() { closeToast() {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="questionTitle">{{ curPageData?.pageName }}</div> <div class="questionTitle">{{ curPageData?.pageName }}</div>
<ul class="option_item" style="margin-top: 20%;"> <ul class="option_item" style="margin-top: 20%;">
<li *ngFor="let options of curPageData?.questions[0]['options']" (click)="selectedFamily(options)"> <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" src="assets/images/icon{{ options.optionId }}.png"
alt="{{ options.optionName }}"/> alt="{{ options.optionName }}"/>
<span>{{ options.optionName }}</span> <span>{{ options.optionName }}</span>
......
...@@ -32,7 +32,14 @@ export class FamilyComponent implements OnInit { ...@@ -32,7 +32,14 @@ export class FamilyComponent implements OnInit {
// 选择家庭结构 // 选择家庭结构
selectedFamily(option) { selectedFamily(option) {
this.selectedOptionId = option.optionId; 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 = { this.pageAnswers = {
pageId: this.curPageData['pageId'], pageId: this.curPageData['pageId'],
questions: [{ questions: [{
...@@ -42,7 +49,7 @@ export class FamilyComponent implements OnInit { ...@@ -42,7 +49,7 @@ export class FamilyComponent implements OnInit {
}], }],
}; };
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
// console.log(this.pageAnswers) console.log(this.pageAnswers)
} }
// 下一步 // 下一步
......
...@@ -115,6 +115,7 @@ export class LiveComponent implements OnInit { ...@@ -115,6 +115,7 @@ export class LiveComponent implements OnInit {
this.nextBtn = false; this.nextBtn = false;
} }
// console.log(this.pageAnswers); // console.log(this.pageAnswers);
console.log(this.commonService.todos)
} }
next() { 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