angular - 将多个值存储在一个数组中并以表格形式显示
问题描述
我已将多个值推送到 component.ts 文件中名为 MyArrayType 的数组中,但希望将其显示到 component.html 文件中的表格形式中。它们是我可以将其存储到变量或某种数据绑定中的一种方式吗?
if(this.disableEveryday == false){
this.MyArrayType.push(
this.everydayAllFromValue,
this.everydayBreakfastFromValue,
this.everydayDinnerFromValue,
this.everydayLunchFromValue)
}
else{
this.MyArrayType.push(
this.mondayAllFromValue,
this.mondayBreakfastFromValue,
this.mondayDinnerFromValue,
this.mondayLunchFromValue,
this.tuesdayAllFromValue,
this.tuesdayBreakfastFromValue,
this.tuesdayDinnerFromValue,
this.tuesdayLunchFromValue,
this.wednesdayAllFromValue,
this.wednesdayBreakfastFromValue,
this.wednesdayDinnerFromValue,
this.wednesdayLunchFromValue,
this.thrusdayAllFromValue,
this.thrusdayBreakfastFromValue,
this.thrusdayLunchFromValue,
this.thrusdayDinnerFromValue,
this.fridayAllFromValue,
this.fridayBreakfastFromValue,
this.fridayLunchFromValue,
this.fridayDinnerFromValue,
this.saturdayAllFromValue,
this.saturdayBreakfastFromValue,
this.saturdayLunchFromValue,
this.saturdayDinnerFromValue,
this.sundayAllFromValue,
this.sundayBreakfastFromValue,
this.sundayLunchFromValue,
this.sundayDinnerFromValue)
}
解决方案
由于很难解释您的问题,但这是以表格形式显示数据的代码 -
<table>
<tbody *ngFor="let element of MyArrayType; let j=index">
<tr>
<td>{{element}}</td>
</tr>
</tbody>
</table>
推荐阅读
- emacs - Emacs 的搜索/提升孔 Idris 命令
- sql - 运行更新语句的意外结果
- c# - 如何在 json 结果中格式化自定义类型?
- c# - 如何在实体框架中的多个数据库之间共享类?
- python - IllegalArgumentException - H2O 在 Python 中导入 MOJO 文件失败
- php - 为什么 PHP PSR-11 Container 不提供设置依赖的方法?
- javascript - 将带参数的函数添加到变量
- java - 单击时的 JavaFx TabPane 样式
- ios - AVAudioEngine 从网络中获取数据并在有噪音或无声的情况下播放
- jquery - 如何在从 jquery ajax 调用成功返回时显示 JQuery 对话框