首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何连接fire NG2-smart-table创建数据

如何连接fire NG2-smart-table创建数据
EN

Stack Overflow用户
提问于 2019-04-07 23:01:37
回答 1查看 221关注 0票数 0

我一直在使用ng2-smart-table模板。单击add new button.some one now可以帮助我后,我无法找到数据保存的位置。

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-08 00:00:37

根据Documentation,上述模块的DataSource只是一个数组或LocalDataSource对象。

让我们举个例子。在typescript文件中定义如下数组。

代码语言:javascript
复制
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)上。

代码语言:javascript
复制
<ng2-smart-table (createConfirm)="addData($event)" [settings]="settings"
                       [source]="data"></ng2-smart-table>

同样是在模板上。

代码语言:javascript
复制
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
}

单击ctrate confim时,将调用上述addData(event)函数。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55560367

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档