I am writing a cellRenderer
component for ag-grid
.
If I write it like below, it works fine :
function SignalCellRenderer() {}
SignalCellRenderer.prototype.init = function (params) {
// create the cell
this.eGui = document.createElement('div');
this.eGui.innerHTML = '<span class="my-css-class"><button class="btn-simple">Push Me</button><span class="my-value"></span></span>';
};
But if I use the below notation, it fails :
let SignalCellRenderer = () => {}
SignalCellRenderer.prototype.init = function (params) {
// create the cell
this.eGui = document.createElement('div');
this.eGui.innerHTML = '<span class="my-css-class"><button class="btn-simple">Push Me</button><span class="my-value"></span></span>';
};
with this error message
TypeError: Cannot set property 'init' of undefined
I thought those 2 ways of defining a function were equivalent but clearly not.
Could someone please explain the difference ?