I've a custom component for displaying phone numbers (stm-phone-number). It has an @Input() parameter called phoneNumber. When I try to bind data to it in a *ngFor, I get this error message:
Can't bind to 'phoneNumber' since it isn't a known property of 'stm-phone-number'.
Here's my code:
import { Component, OnInit, Input} from '@angular/core';
import { KeyValueModel } from '../../models/types/key-value';
@Component({
moduleId: module.id,
selector: 'stm-phone-number',
templateUrl: './phone-number.component.html',
styleUrls: [ './phone-number.css' ],
providers: [],
directives: []
})
export class PhoneNumberComponent implements OnInit
{
@Input() phoneNumber: KeyValueModel<string,string>;
constructor ()
{
}
ngOnInit()
{
}
}
and here's how I'm using it:
<section class="grid-block" *ngFor="let entry of PhoneNumberList">
<stm-phone-number [phoneNumber]="entry"></stm-phone-number>
</section>
NOTE: PhoneNumberList is an array of KeyValueModel<string,string>
How do you bind an iterative value inside ngFor to an @Input property of a custom component?