2017-03-06 3 views
-1

각도로 GET 청원을 한 후에는보기가 올바르게 업데이트되지 않습니다.청원을 얻은 후에 Angular2보기가 올바르게 표시되지 않습니다.

GET 청원은 옵션이있는 드롭 다운 메뉴를 채우는 데 사용되지만, 문제는 드롭 다운에 배열에 삽입 된 마지막 옵션 만 표시된다는 것입니다. 콘솔 로그에서 배열의 모든 요소를 ​​볼 수 있습니다.

<div class="dropdown center"> 
    <button class="btn btn-xs btn-default dropdown-toggle" type="button" data-toggle="dropdown" style="border-radius: 10px;"> 
     <i style="color: gray; margin: 5px;" class="fa fa-line-chart " aria-hidden="true"></i> Oferta <span class="caret"></span> 
    </button> 
    <ul *ngFor="let li of tabOferta" class="dropdown-menu"> 
     <li><a (click)="setChange(li,0)">{{li}}</a> 
     </li> 

    </ul> 
</div> 

와 타이프 스크립트 코드 : 내가 무엇을 누락

tabOferta: string[] = []; 
    this.indicadorService.getIndicadoresCatalogo().then(data => { 

    this.zone.run(() => { 
    for (let d of data) { 
     switch (d.indicador) { 
     case "oferta": { 

      for (let clave of d.clave) { 
      this.tabOferta.push(clave); 
      } 

      break; 
     } 
     case "demanda": { 

      for (let clave of d.clave) { 
      this.tabDemanda.push(clave); 
      } 

      break; 
     } 

     case "seguridad": { 

      for (let clave of d.clave) { 
      this.tabDemanda.push(clave); 
      } 


      break; 
     } 

     case "mercadotecnia": { 

      for (let clave of d.clave) { 
      this.tabDemanda.push(clave); 
      } 


      break; 
     } 
     case "comunidad": { 

      for (let clave of d.clave) { 
      this.tabDemanda.push(clave); 
      } 


      break; 
     } 
     case "accesibilidad": { 

      for (let clave of d.clave) { 
      this.tabDemanda.push(clave); 
      } 


      break; 
     } 

     default: { 

      break; 
     } 
     } 
    } 

    }); 


}); 

이 HTML 코드는? 왜 단 하나의 옵션 만 표시됩니까?

+1

에 넣으십시오. ul – Gab

답변

1

귀하의 * ngFor를 ul 요소가 아닌

관련 문제