【发布时间】:2019-04-08 00:19:40
【问题描述】:
我一直在使用 ng2-smart-table 模板。单击添加新按钮后,我无法找到数据保存的位置。现在有人可以帮助我。
在此表中创建数据并在列表中显示我们创建的数据。但情况是,如果我们刷新浏览器,上面提到的数据没有保存。那么我应该怎么做才能为firestore添加这些数据。
【问题讨论】:
标签: ng2-smart-table
我一直在使用 ng2-smart-table 模板。单击添加新按钮后,我无法找到数据保存的位置。现在有人可以帮助我。
在此表中创建数据并在列表中显示我们创建的数据。但情况是,如果我们刷新浏览器,上面提到的数据没有保存。那么我应该怎么做才能为firestore添加这些数据。
【问题讨论】:
标签: ng2-smart-table
根据Documentation,上述模块的DataSource只是一个数组或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时被调用。
【讨论】: