I have a delay function in a lighting component helper from which I want to call another function I get the error [this.displayToast is not a function] how do I achieve this?
Delay function:
callbackOnceAfterDelay : function(cmp, helper){
var delay=60000; //1 min
setTimeout(function() {
console.log('Inside delay: ');
this.displayToast(cmp, 'success', 'Thanks');
}, delay);},
Function to call:
displayToast: function(cmp, type, message, messageTemplate, templateData) {
var toastEvent = $A.get('e.force:showToast');
toastEvent.setParams({
type: type,
message: message,
messageTemplate: messageTemplate,
messageTemplateData: templateData
});
toastEvent.fire();
}
callbackOnceAfterDelay
anddisplayToast
Is it a controller or a helper method?