首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Angular 5-表格格式错误(html页面)

Angular 5-表格格式错误(html页面)
EN

Stack Overflow用户
提问于 2018-07-12 02:50:00
回答 1查看 69关注 0票数 -1

提前感谢您的帮助。

我在使用服务从angular类格式化我的表格时遇到了问题。

将显示我的表格,但它们在每个单元格之间包含逗号(,)。我想坐上那辆车。

在HTML中

代码语言:javascript
复制
<table>
   <thead>
      <tr>
        <th>Period</th>
        <th *ngFor="let m of types.Testing">
          {{m.colors}}
        </th>
      </tr>
    </thead>
    <tbody>
      <th></th>
    </tbody>
</table>

组件

代码语言:javascript
复制
import { Component } from '@angular/core';
import {Mytypes} from './model';
import { myserv } from './shared.service';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
    name = 'Angular 6';

    public types: Mytypes;

    constructor(public _service: myserv) {}

    ngOnInit() {
      this.types = this._service.GetData(true);
    }
}

服务文件

代码语言:javascript
复制
import { Injectable } from '@angular/core';
import {Mytypes, types} from './model';

@Injectable()

export class myserv{

  //sourc - not currently in use
  GetData(sourc: boolean): Mytypes{

    var view = new Mytypes();

    var main = new types();
    main.tests= [
      "--"
    ];
    main.colors= [
      "Blue" , "Red" , "Yellow"
    ];

    view.Testing = [
      main 
    ]

    return view;
}

  constructor() { }
}

模型

代码语言:javascript
复制
import { Injectable } from '@angular/core';

@Injectable()
export class types{

  public tests: Array<string>;
  public colors: Array<string>;

  constructor() { }
}

@Injectable()
export class Mytypes{

  public Testing: Array<types>;
  constructor() { }
}

当前显示为:

代码语言:javascript
复制
Blue,Red,Yellow

预期显示为:

代码语言:javascript
复制
Blue   Red   Yellow

问题发布地址:https://stackblitz.com/edit/angular-zdame7?file=src%2Fapp%2Fapp.component.ts

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

https://stackoverflow.com/questions/51292373

复制
相关文章

相似问题

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