What is the difference between defining a model as an interface or as a class in IONIC?

0

I'm a beginner in programming and my input language is Java.

Studying some projects with Ionic, I found one that used an interface to define a model, for example:

export interface Pessoa {
   nome: string;
   idade: number;
 }

I remember that the basic difference between a class and an interface is that the interface does not implement behaviors.

I know that Ionic is based on TypeScript. What is the reason for adopting this practice?

I know that TypeScript is not Java but as Java is my reference, where should I get the methods of the Person (or interface) class in Ionic?

    
asked by anonymous 06.09.2018 / 04:47

1 answer

0

In the link below there is a more in-depth tutorial on the issue.

link

But briefly, if you want a model that has only attributes and no method, use an interface. Otherwise, create a class to implement methods.

But remembering that even then, an interface can be extended into a class.

    
08.09.2018 / 04:39