Aug 15, 2022
You actually can, but it's a terrible practice, just as implementing ngOnChanges. Every change detection cycle will trigger the function (try it with a console.log and watch the console drive crazy). A way of solving this is using the OnPush change detection strategy and changeDetectorRef.markForCheck() on every piece of code that requires it. But still, it is a terrible practice.