首页 > 解决方案 > Angular 中 WebService 上的下拉列表

问题描述

我有一系列关于网络服务的问题。

我知道如何通过 for 循环检索我的录音(我的问题)。

HTML

<ul class="listing" *ngFor="let item of questions" >
    <li>- {{item}}</li>
</ul>

TS

    questions;
    selectedQuestion;
    
    this.api.getUserStatus(this.user)
    .subscribe((response) => {
                
        console.log("HELLO : " + JSON.stringify(response));

        if (response['PAGEACCEUIL'].ISFIRST == "TRUE") {
                    
            this.goToFase(3);
        } else {
                    
            this.goToFase(2);
        }
        
        this.questions = response['PAGEACCEUIL'].TEXTE.QUESTION
        this.selectedQuestion = response['PAGEACCEUIL'].TEXTE.QUESTION

        console.log("My Questions  (Display): " + JSON.stringify(this.questions));
        console.log("My Questions (DROPDOWN) : " + JSON.stringify(this.selectedQuestion));              
});

我得到我的录音

在此处输入图像描述

现在,我想使用一个下拉列表,但我不懂语法...

我的下拉列表是空的……我检索了 11 次item,但不是我的录音。

<select>
       <option *ngFor="let item of selectedQuestion"> {{item}</option>
 </select>
       

标签: angular

解决方案


推荐阅读