如何连接 fire base ng2-smart-table 的创建数据

How to connect fire base ng2-smart-table's create data

我一直在使用 ng2-smart-table 模板。点击添加新后找不到数据保存的位置button.some现在可以帮助我

在此table中创建数据并在列表中显示我们创建的数据。但情况是,如果我们刷新浏览器,上述数据不会保存。那么我应该怎么做才能为 firestore 添加这些数据。

根据Documentation.

,上述模块的数据源只是一个数组或 LocalDataSource 对象

举个例子。 在打字稿文件上定义一个这样的数组。

data = [
  {
    id: 1,
    name: "Leanne Graham",
    username: "Bret",
    email: "Sincere@april.biz"
  },
  {
    id: 2,
    name: "Ervin Howell",
    username: "Antonette",
    email: "Shanna@melissa.tv"
  },

  // ... list of items

  {
    id: 11,
    name: "Nicholas DuBuque",
    username: "Nicholas.Stanton",
    email: "Rey.Padberg@rosamond.biz"
  }
];

settings = {
  columns: {
    id: {
      title: 'ID'
    },
    name: {
      title: 'Full Name'
    },
    username: {
      title: 'User Name'
    },
    email: {
      title: 'Email'
    }
  },
add:{
 confirmCreate:true
},
mode:'inline'
};

在模板上(html)。

<ng2-smart-table (createConfirm)="addData($event)" [settings]="settings"
                       [source]="data"></ng2-smart-table>

再次使用模板。

addData(event){
//event.data is the newely created data
// Handle newly created data
// Shape of object is  {
//    id,
//    name,
//    username,
//    email,
//  }
// You must call event.confirm.resolve() to show data on table
}

上面的addData(event)函数在点击ctrate confim时调用。