I have a function that creates random values but I want to know how to add this function when I create a new record in a ng2-smart-table. I'm creating users and I need to assign them a random id.
This is my random id code:
stringGen(len) {
var text = "";
var charset = "abcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < len; i++)
text += charset.charAt(Math.floor(Math.random() * charset.length));
return text;
}
randomID = this.stringGen(8);
this is my html: list-user.component.html
<ng2-smart-table
[settings]="settings"
[source]="roles">
</ng2-smart-table>
this is my ts: list-user.component.ts
settings = {
columns: {
role_id : {
title: 'Role ID',
},
role_desc : {
title: 'Role Description',
editor: {
type: 'textarea',
}
}
}
}