I am using Lightning toast messages in my lightning controller.
But I am getting error like "Cannot read property 'setParams' of undefined"
Below is my code:
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": "Error!",
"message": "Plase provide 'Part Number' to add to the list."
});
toastEvent.fire();
Best Answer
If you want to use toast in ltng:out/VF page i.e out of one.app container, you need to implement your own toast component and call/create the component from parent component. You can refer following component I created:
Pass required parameters and set them in controller:
})
})