I have the following error appear when I try passing the index of a *ngFor loop through into a component.
Can't bind to 'count' since it isn't a known property of 'app-details'
It seams I can't pass the index through.
First file
import { Component } from '@angular/core';
import { App } from 'reg.interface';
@Component({
selector: 'reg',
styleUrls:['reg.component.scss'],
template:`
<div class="container">
<div class="col-6">
<h2>App Details:</h2>
<app-details *ngFor="let app of apps; let i = index;"
[details]="app"
[count]="i"
</app-details>
</div>
</div>
`
})
export class RegComponent {
apps: App[];
}
Second file
import { Component, Input } from '@angular/core';
import { App } from 'reg.interface';
@Component({
selector: 'app-details',
template: `
<div class="col-12">
<span>Index: {{ details | json }}</span>
<span>Index: {{ count }}</span>
</div>
`
})
export class AppDetailsComponent {
@Input()
app: App;
count: number;
}
reg.interface
export interface App {
type: string,
price: number
}
I'm importing the BrowserModule + CommonModule in my main app.module
Any help much appreciated - I can always add more details to the question etc if required. Thanks
app-detailsand not<app-details></app-details>