Correct way of defining a model in Ionic 3

一个人想着一个人 提交于 2019-12-06 09:37:16

Typescript supports accessors natively, which effectively handle the job of getters and setters. You don't need to manually define them as separate methods.

With typescript, you can just define it like below.You don't need to do big work.Typescript will do the rest.

TypeScript supports getters/setters as a way of intercepting accesses to a member of an object. This gives you a way of having finer-grained control over how a member is accessed on each object.

export class ItemModel {
    name: string;
    note: string;
}

let itemModel = new ItemModel();
itemModel.name= "My Name";
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!