简体   繁体   中英

Json object pass as param in dynamicallay created element click event using javascript/angularjs

Json object pass as param in dynamicallay created element click event using javascript/angularjs

var _dataObj = "{"sor_SourcingAgentId":1,"sor_Name":"xx"}"

var _dynHtml=  '<input type="button"  ng-click="fnSelectcustomer(\'' + _dataObj + '\',\'' + data['sor_Name'].toString() + '\',\'' + data['sor_SourcingAgentId'].toString() + '\')" value="select"/>';

thanks in advance

If click event is not working in your code then use this

var _dynHtml= '<input type="button" ng-click="fnSelectcustomer(\\'' + _dataObj + '\\',\\'' + data['sor_Name'].toString() + '\\',\\'' + data['sor_SourcingAgentId'].toString() + '\\')" value="select"/>';

add below code in your controller

$compile(_dynHtml)($scope);

It will call your function. I guess this is what your looking for

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM