Struggling with an error while developing a demo app in Angular 2. The error message reads:
core.umd.js:3491 EXCEPTION: Uncaught (in promise): Error: Error in security.component.html:35:72 caused by: trackBy must be a function, but received undefined. Error: trackBy must be a function, but received undefined
If anyone has any suggestions on what might be the issue with the following code, please let me know:
security.component.html:
<h2>Template :</h2>
<template ngFor let-hero [ngForOf]="heroes" let-i="index" let-odd="odd" [ngForTrackBy]="trackById">
<div [class.odd]="odd">({{i}}) {{hero.name}}</div>
</template>
security.component.ts:
import { Component,Input } from '@angular/core';
@Component({
moduleId : module.id,
selector : 'security-component',
templateUrl : '../views/security.component.html'
})
export class securityComponent{
private heroes = [
{id: 11, name: 'Mr. Nice' },
{id: 12, name: 'Narco' },
{id: 13, name: 'Bombasto' },
{id: 14, name: 'Celeritas' },
{id: 15, name: 'Magneta' },
{id: 16, name: 'RubberMan' },
{id: 17, name: 'Dynama' },
{id: 18, name: 'Dr IQ' },
{id: 19, name: 'Magma' },
{id: 20, name: 'Tornado' }
];
}