Share same model between front-end and server

Viewed 961

Simple question but I would like to know how to do this effectively. Very prone to attract negative votes.

I have a model which I want to share between front-end and back-end. For front-end manually I want to add few attributes. These attributes are not required for back end.

export class ModelA {
id: string;
name: string;
value: number;
}

above is sufficient for server (back-end).

But in front end I need to do one extra thing.Based on value I need to define color attribute (value < 10, color green etc..)

export class ModelA {
id: string;
name: string;
value: number;
color: string;
}

So when I'm updating ModelA back to the server after editing id/name whatever I don't want to pass color attribute.

With single model how could I achieve this?

1 Answers
Related