首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >吴氏角9度反射

吴氏角9度反射
EN

Stack Overflow用户
提问于 2020-03-23 03:25:39
回答 1查看 461关注 0票数 0

我试着做一个*ngFor,但看起来是这样的:ng-reflect for-of。当使用de日志时,变量工作良好。

代码html:

代码语言:javascript
复制
<table class="table">
  <thead class="thead-dark">
    <tr>
      <th *ngFor="let cabecera of cabeceras">hello {{ cabecara }}</th>
    </tr>
  </thead>
</table>

代码.ts:

代码语言:javascript
复制
import { Component, OnInit, Input } from '@angular/core';
import { ProductoService } from '../../services/Producto.Service';


@Component({
  selector: 'tabla-producto',
  templateUrl: './tabla-producto.component.html'
})

export class TablaProductoComponent implements OnInit { 

cabeceras: string[];

@Input()  productos: any[] = [];


  constructor(private producto: ProductoService) {
    this.cabeceras = ['Id Producto', 'Nombre', 'Precio', 'Stock', 'Nombre Categoria'];
  }


  // Todo lo que pongamos aquí abajo, se ejecutará al cargar la página
  ngOnInit(){
    this.producto.getProducto().subscribe((data: any) => {
     // console.log("imprime objeto data")
     // console.log(data);
      this.productos = data;

      console.log("imprime objeto productos")
      console.log(this.productos);
    });
  }

}

图像控制台

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-03-23 03:51:00

你有个打字错误

代码语言:javascript
复制
<table class="table">
  <thead class="thead-dark">
    <tr>
      <th *ngFor="let cabecera of cabeceras">hello {{ cabecara }}</th>
    </tr>
  </thead>
</table>

你写的是cabecara而不是cabecera

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60807584

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档