如何将angular 2变量的值传递给javascript函数?

时间:2016-08-27 12:38:52

标签: javascript html angular

enter image description here

这是我的形象 我想在图像中给出的onclick函数中传递“c.name”和“c.image_Url”

1 个答案:

答案 0 :(得分:1)

$documents = $collection->find([ //conditions here ]);

// iterate through each row/document
foreach ($documents as $document) {
  //grab the keyword
  $keyword = $document['keyword'];
  // make an API request
  $AdditionalData = APIRequest($keyword, $arguments);
  // store fetched data in another collection
  $anotherCollection->insert($AdditionalData);
}

在组件中,

<div *ngFor="let c of categories" (click)="selectedCategory(c.name,c.image_url)">

     //<---note (click) event - angular2 way element's click binding
     ....

</div>