Passing loop item to child component in Angular 2.

854 views
Skip to first unread message

Jamie Phillips

unread,
May 5, 2017, 11:57:34 PM5/5/17
to Angular and AngularJS discussion
I have a parent component with a list of Item objects.  In the template, I am looping over them and creating an Item component object for each one, but I need to pass the relevant Item object into each child component.  I'm getting the error: "Unable to resolve signature of property decorator when called as an expression. Supplied parameters do not match any signature of call target.".  Can someone tell me where I'm going wrong here?

The parent template includes this:

<app-item *ngFor="let item of (items | itemFilter:getFilterArguments())" [item]="item"></app-item>

The child component:

 import { Component, OnInit, Input } from '@angular/core';
@Component({
  selector: 'app-item',
  templateUrl: './item.component.html'
})
export class ItemComponent implements OnInit {
  @Input item:Item;
  constructor() {}
  ngOnInit() {
  }
}
 

Sander Elias

unread,
May 6, 2017, 12:53:27 AM5/6/17
to Angular and AngularJS discussion
Hi Jamie,

replace:
 @Input item:Item;

with:
 @Input() item:Item;


Regards
Sander
Reply all
Reply to author
Forward
0 new messages