If you are using angular5 and above, please include the below method in your ts file.
async delay(ms: number) {
await new Promise(resolve => setTimeout(()=>resolve(), ms)).then(()=>console.log("fired"));
}
then call this delay() method wherever you want.
e.g:
validateInputValues() {
if (null == this.id|| this.id== "") {
this.messageService.add(
{severity: 'error', summary: 'ID is Required.'});
this.delay(3000).then(any => {
this.messageService.clear();
});
}
}
This will disappear message growl after 3 seconds.