May 27, 2022
Hi Hiep,
Thanks for the wonderful question.
As I mentioned in the article, the inject operation must be called in the injection context (AKA: constructor context), so if you are using inject() in ngOnInit or any other method, it will throw this error.
Please check the paragraph just before BONUS in More Powerful Dependency Injection section.