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
Post a Comment