Angular Series #5: Interfaces in Angular

In this article, we will see how to use interfaces in angular,

Interface in typescript is also the same as other object-oriented programming languages. The interface is of the abstract type which contains a declaration of properties, Methods, and Events. Implementation of interface members provided by the class which implements the interface.

Let’s take an example of a product component which will contain a list of product and display the same in its view. As in out prod-detail.component.ts we defined array products of any type because of which we are not using strongly typed feature of typescript now we will check how we can include strongly typed feature using the interface,

product.ts — Interface


Key points:

1) Interface members are public by default and do not require explicit access modifiers. If you add explicit access modifies it will throw compile-time error.

2) A class that implements an interface must provide an implementation for all the interface members unless the members are marked as optional? parameter.

3) Use the implement keyword to make a class implement interface.

Thank You, See you in the next article !!

You can reach out to me here,



Technical Speaker | Computer Engineer | Full Stack Web Developer | ML Enthusiast | * Knowledge Shared = Knowledge² *