In the following code block heros
is wrapped with curly braces:
export class InMemoryDataService implements InMemoryDbService {
createDb() {
let heroes = [
{id: 11, name: 'Mr. Nice'},
{id: 12, name: 'Narco'},
...
];
return {heroes};
}
}
In particular reason for this?
Yes, you return it as an object that looks like this:
{
heroes: heroes
}
It's a "shortcut" to use this form: { heroes }
.
More on this here: Object initializer - New notations in ECMAScript 2015
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With