Call a function inside ngFor in angular2

后端 未结 9 1857
眼角桃花
眼角桃花 2020-12-06 05:08

Hello I am using Angular2 and wanted to fetch the server and get some values for each ID I get inside ngFor.

9条回答
  •  我在风中等你
    2020-12-06 05:59

    Not sure if this is what you're asking, but you can pass in the item to a function along with an event variable like this:

    And then grab that item in your class like this:

    functionCall(event, item): void {
      console.log('item clicked:", item)
    }
    

提交回复
热议问题