2021年1月18日星期一

How to pass an object as a param to ng-click with javascript

I used HTML snippet on javascript to pass an object to a function but it didn't work.

var obj = { LocationID: location.LocationID, OrderID: c.ID };  str += `<div class="col-md-9">${c.OrderCode}</div>  <div class="col-md-1" ng-click="$ctrl.iconClicked($event, 'remove', ${obj})"><i class="fa fa-times" style="color:#FF0000" title="Remove order"></i></div></div>`;  

The param only accepts value.

str += `<div class="col-md-9">${c.OrderCode}</div>  <div class="col-md-1" ng-click="$ctrl.iconClicked($event, 'remove', ${location.LocationID}, ${c.OrderID})"><i class="fa fa-times" style="color:#FF0000" title="Remove order"></i></div></div>`;  
https://stackoverflow.com/questions/65784970/how-to-pass-an-object-as-a-param-to-ng-click-with-javascript January 19, 2021 at 11:05AM

没有评论:

发表评论