angular - typescript models from classes, why? -


i'm new typescript, i'm using build angular apps. see models this

export interface item {     name: string } 

and see

export class lesson {  constructor(     public $key:string) } 

with static methods

static fromjson({$key}) {}  

whats benefit?

interface allows create model properties only.

however, class gives advantage define , use functions.

e.g. if want initialize object, interface have initialize properties, whereas class can same class constructor.

its user want use. in opinion, model using class gives more flexibility compared interface.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -