I am trying to replicate the chips example found at this link (https://material.angularjs.org/latest/#/demo/material.components.chips) using TypeScript. I have just started learning TypeScript this week and I am having some difficulties translating this code from JavaScript to TypeScript:
JS:
function mockLabels() {
var labels = [
{
'name': 'hotel',
'id': '1'
},
{
'name': 'sport',
'id': '2'
},
{
'name': 'gaming',
'id': '3'
}
];
return labels.map(function (lab) {
lab._lowername = lab.name.toLowerCase();
return lab;
});
}
TypeScript:
private mockLabels: Array<Label> = [
new Label(1, 'hotel'),
new Label(2, 'sport'),
new Label(3, 'gaming')
];
public getLabels() {
return this.mockLabels;
}
I am struggling to incorporate .map into my TypeScript code after assigning it to an array in TypeScript.
How can I modify mockLabels to achieve this?