I have a component, which i want to use like this
<comp [list]="['alpha', 'bravo', 'charlie']"></comp>
i.e, i want it to display the contents of a list.
The compontent's code is
@Component({
selector: 'comp',
template: `
<ul>
<li *ngFor="item of decoratedList()">
- -
</li>
</ul>`
})
class Comp {
list: any[];
decoratedList(): any[] {
return this.list.map(item => ({
name: item,
foo: fooIt(item),
bar: barIt(item)
}));
}
}
The Problem with this code is decoratedList, because it returns a new list every check, due to it's use of map, which leads to decoratedList() has Changed-type errors.
What is an ideomatic way in angular to handle such a pattern?
Aucun commentaire:
Enregistrer un commentaire