I am creating an HTML element in a variable as a string and calling a function on its click. The issue is that when I am trying to pass an object to the function as a parameter, it is not being sent properly. When the function is called, I am simply consoling the object passed and it is logging [object Object], so its not accessible as an object. What am i doing wrong?
fnCreateElement: function(obj) {
let mainObj = obj
console.log('JSON received ----', obj)
let el = '<span class="field-actions d-block">' +
'<i id="edit" class="fa fa-pencil pr-3 pointer" onclick="openModal(\'' + obj + '\')" aria-hidden="true"></i>' +
'<i class="fa fa-times pointer" aria-hidden="true" onclick="removeElement(\'' + obj.id + '\')"></i>' +
'</span>';
The first console is printing the object properly in the fnCreateElement function but when the openModal function is called, it is causing the issue.
openModal = (obj) =>{
console.log(obj) // output ---> [object Object]
}