当前位置: 代码迷 >> 综合 >> angular 4 ---------------添加和编辑功能
  详细解决方案

angular 4 ---------------添加和编辑功能

热度:56   发布时间:2023-12-24 14:18:06.0
add() {this.tittle = '添加';// 遍历headers每个值this.headers.map( v => {v['val'] = '';});this.show_form = true;this.show_table = false;
}
edit(index) {// 将数据表的数据赋值给headers对应的值// index是个对象  如:index={i;2}this.tittle = '编辑';const i = index['i'];console.log('edit', this.data);this.headers.map(d => {console.log('-----------',d)switch (d.type) {case 'input':d.val = this.data[i][d.key];break;case 'select':d.val = this.data[i][d.key];break;case 'select-line':d.val = '';break;case 'fuzzy_select':d.val = this.data[i]['role'];console.log('========', d.val);break;default:d.val = this.data[i][d.key];}this.show_form = true;this.show_table = false;});
}
  相关解决方案