第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何在給定的對(duì)象中以串行方式檢索索引值

如何在給定的對(duì)象中以串行方式檢索索引值

眼眸繁星 2022-06-16 17:17:17
在給定的對(duì)象中,有不同的問(wèn)題集。(標(biāo)簽,問(wèn)題文本),每個(gè)對(duì)象集都有“QuestionTypeId”。如果 QuestionTypeId 為“18”,則問(wèn)題為“標(biāo)簽”,標(biāo)簽不應(yīng)包含數(shù)字(索引值)。每個(gè)標(biāo)簽可能有一個(gè)或多個(gè)帶有索引值的 questionText。在這里,我只需要向 QuestionTypeId 不同而不是“18”的 questionText 顯示索引值。只有那些問(wèn)題文本編號(hào)或索引值需要連續(xù)添加,下面是以正確格式顯示的圖像。圖像中顯示的結(jié)果是我試圖得到下面是我試圖得到結(jié)果的代碼:export class AppComponent implements OnInit {  globalJsonData = {    "parent": {      "child": [{          "QuestionId": 349,          "QuestionText": "This is Label One",          "QuestionTypeId": 18,          "QuestionSetCode": 166378        },        {          "QuestionId": 340,          "QuestionText": "This is Question Text One",          "QuestionTypeId": 17,          "QuestionSetCode": 166378        },        {          "QuestionId": 350,          "QuestionText": "This is Label Two",          "QuestionTypeId": 18,          "QuestionSetCode": 166378        },        {          "QuestionId": 352,          "QuestionText": "This is Question Text Two",          "QuestionTypeId": 17,          "QuestionSetCode": 166378        },        {          "QuestionId": 354,          "QuestionText": "This is Question Text Three",          "QuestionTypeId": 6,          "QuestionSetCode": 166378        },        {          "QuestionId": 350,          "QuestionText": "This is Label Three",          "QuestionTypeId": 18,          "QuestionSetCode": 166378        },        {          "QuestionId": 353,          "QuestionText": "This is Question Text Four",          "QuestionTypeId": 17,          "QuestionSetCode": 166378        },        {          "QuestionId": 355,          "QuestionText": "This is Question Text Five",          "QuestionTypeId": 8,          "QuestionSetCode": 166378        }      ]    }  }使用上述解決方案,我得到了這個(gè)結(jié)果:請(qǐng)幫助我獲得解決方案,或?yàn)槊總€(gè)跳過(guò)標(biāo)簽的問(wèn)題文本以串行方式索引值。
查看完整描述

1 回答

?
素胚勾勒不出你

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超9個(gè)贊

你應(yīng)該循環(huán)li不上ul。它也可以以更簡(jiǎn)單的方式完成。


你應(yīng)該這樣做:


在component.ts文件中,按如下方式處理您的數(shù)據(jù):


callGenerateConfig() {

    let data = [];

    data = this.globalJsonData.parent.child;

    let position = 1;


    data.forEach((item, index) => {

      let isLabel = item.QuestionTypeId === 18;

      console.log(isLabel);

      let obj = {

        label: isLabel,

        data: item,

        location: position

      }

      if (!isLabel) {

        position++;

      }

      this.questionList.push(obj);

    })

  }

在component.html下面做:


<ul>

   <li *ngFor="let data of questionList">

      <span *ngIf="data.label===false"> {{data.location}}</span>

      <span> {{data.data.QuestionText}}</span>

   </li>  

</ul>


查看完整回答
反對(duì) 回復(fù) 2022-06-16
  • 1 回答
  • 0 關(guān)注
  • 84 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)