万物皆组件思想,组件化开发,优化项目,省时省力
1,使用命令创建一个表单component
ionic g component select-table
//其他指令
ionic g page YourPageName //创建新页面
ionic g directive YourPageName //创建指令
ionic g component YourComponentName //创建组件
ionic g provider YourProviderName //创建服务
ionic g pipe YourPipeName //创建过滤器
或者手动创建
结果如图
2,编写组件代码
select-table.html
<div>
<table align="center" border="1">
<tr>
//父组件传入表头
<td
*ngFor="let j of thMap">{
{j}}</td>
</tr>
//遍历表单数据
<tr *ngFor="let x of resMap;let idx=index"
(click)="selectTR(idx)"
[ngClass]="{'selectCls':selectIdx === i