我一直在使用ng2-smart-table模板。单击add new button.some one now可以帮助我后,我无法找到数据保存的位置。
在此表中创建数据,并在列表中显示我们创建的数据。但情况是,如果我们刷新浏览器,上面提到的数据不会被保存。那么我应该怎么做才能为firestore添加这些数据呢?
发布于 2019-04-08 00:00:37
根据Documentation,上述模块的DataSource只是一个数组或LocalDataSource对象。
让我们举个例子。在typescript文件中定义如下数组。
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
}单击ctrate confim时,将调用上述addData(event)函数。
https://stackoverflow.com/questions/55560367
复制相似问题