What happen if i use ngOnInit method without implementing OnInit interface

1.7k Views Asked by At

Can anyone please tell me what will happen if I don't implement onInit interface and still using ngOnInit component lifecycle inside a component?

Since I used ngOnInit lifecycle hook without implementing an interface and it's worked for me the same.

So just wanted to understand why I should implement an interface?

1

There are 1 best solutions below

0
On BEST ANSWER

It will still work as expected.

Interface helps us to avoid spelling and syntax mistakes.

According to recomendations from Angular Style Guide

Lifecycle interfaces prescribe typed method signatures. Use those signatures to flag spelling and syntax mistakes.