Angular 如何在ng2智能表中推送自定义数组对象

Angular 如何在ng2智能表中推送自定义数组对象,angular,ng2-smart-table,Angular,Ng2 Smart Table,在“设置对象”中,我们定义结构以显示名称、标题等字段。我想直接将对象指定给列。 对象包含字段 only.settings = { editable: false, mode: 'inline', add: { confirmCreate: true }, edit: { confirmSave: true, }, actions: { delete: false }, columns: { food: { title

在“设置对象”中,我们定义结构以显示名称、标题等字段。我想直接将对象指定给列。 对象包含字段

only.settings = {
  editable: false,
  mode: 'inline',
  add: {
    confirmCreate: true
  },
  edit: {
    confirmSave: true,
  },
  actions: {
    delete: false
  },
  columns: {
    food: {
      title: 'Food',
      filter: false,
    },
    quantity: {
      title: 'Quantity',
      filter: false,
    },
    unit: {
      title: 'Unit',
      filter: false,
      editor: {
        type: 'list',
        config: {
          list: [
            { value: 'gm', title: 'gm' },
            { value: 'slice', title: 'slice' },
            { value: 'cup', title: 'cup' },
            { value: 'glass', title: 'glass' },
            { value: 'pcs', title: 'pcs' },
            { value: 'ml', title: 'ml' },
            { value: 'bowl', title: 'bowl' },
            { value: 'tbspn', title: 'tbspn' }
          ]
        }
      }
    },
我必须创造

array =>units[]= { value: 'bowl', title: 'bowl' },{ value: 'tbspn', title: 'tbspn' } 
想要分配=>
清单:这是一个单位

但它不起作用。
当我通过web服务调用获取数组时就是这样。

从web服务接收数组后,将要转换的元素映射到智能表中使用的结构

地图参考:

可能是这样的:

config.list = unitsFromWebservice.map(function(unit) {
   return { value: unit, title: unit };
});

从webservice接收数组后,将要转换的元素映射到智能表中使用的结构

地图参考:

可能是这样的:

config.list = unitsFromWebservice.map(function(unit) {
   return { value: unit, title: unit };
});
  • 构建{value:unit,title:unit}对象的数组
  • 将设置对象重新指定为新对象
  • 代码:

  • 构建{value:unit,title:unit}对象的数组
  • 将设置对象重新指定为新对象
  • 代码: