不知道是哪根筋打到
以前這種都可以很正常的subscribe顯示隱藏
但是這次寫卻不會連動顯示隱藏
就是訂閱piqType欄位,
偵測變動時去用值控制isShowQuestionPIQA 和 isShowQuestionPIQB
的*ngIf 顯示隱藏
請大神幫看問題,感謝
HTML
<div
class=""
fxLayout="column wrap"
fxLayoutGap="20px"
*ngIf="isShowQuestionPIQA"
>AAA</div>
<div
class=""
fxLayout="column wrap"
fxLayoutGap="20px"
*ngIf="isShowQuestionPIQB"
>BBB</div>
TS
public isShowQuestionPIQA: boolean;
public isShowQuestionPIQB: boolean;
ngOnInit() {
this.piqTYpeScribe = this.formDataService.serviceFormGroup.controls.bci
.get('piqType')
.valueChanges.pipe()
.subscribe(x => {
this.professionalInvestorQuestionType(x);
});
}
professionalInvestorQuestionType(piqType) {
if (piqType) {
this.switchShowQuestion(piqType);
}
switchShowQuestion(piqTypeValue) {
switch (piqTypeValue) {
case 'aA':
this.isShowQuestionPIQA = true;
this.isShowQuestionPIQB = false;
break;
case 'aB':
this.isShowQuestionPIQB = true;
this.isShowQuestionPIQA = false;
break;
default:
break;
}
}