user5605068
user5605068

Reputation:

angular 2 use method for properties

I want to call the method setItemSrc and use item as parameter. How do I do that?

<img *ng-for="#item of items"
                    [src]="setSrc(item)"
                    [style.left]="item.x"
                    [style.top]="item.y"
                    (click)="clickedItem(item)">
                 </img>

 public setItemSrc(item:Item):string{
       var str:string="/img/item"
       str=str.concat(item.categorie);
       return str;
}

Upvotes: 0

Views: 68

Answers (1)

basarat
basarat

Reputation: 276085

I want to call the method setItemSrc and use item as parameter

[src]="setSrc(item)" should be [src]="setItemSrc(item)"

Upvotes: 2

Related Questions