Main Component :
Html
<event-thumbnail *ngFor='let event1 of events' #thumbnail [event2]="event1" (eventClick)='handleEventClicked($event)'>Hello</event-thumbnail>
<button class='btn btn-primary' (click)="thumbnail.alertFoo()">alert id</button>
<button class='btn btn-primary' (click)='thumbnail.handleClickMe()'>click me!</button>
Event-Thumbnail Componenent
alertFoo(){
alert("id called");
}
handleClickMe(){
this.eventClick.emit('foo');
alert('click');
}
In the above code I am unable to use button using thumbnail -> template variable when using *ngFor ie. no call is made to alertFoo and handleClickMe() via thumbnail. I also tried to wrap it inside div and still it doesnt work. It only works when I am enclosing the whole code inside a div with *ngFor i.e. also buttons which displays undesirable multiple buttons. I want to understand how ngFor works is there some work around for the above where i want events to be repeated but the buttons to be displayed only once.
thumbnailreferring to? Not really sure, that's why I am asking. You are providing very little code to try and solve this issue. Best would be if you could reproduce the issue in a plunker... :) - AT82