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

python 2.7 - Given three nested dictionaries, sort the top two nested dictionaries from a value in the innermost dictionary? -

angular - DownloadURL return null in below code -