-1

Have a question on ignoring unnecessary object properties brought along with a Back-End model.

Can you plz provide your inputs ?

Let us say that an API is returning below object

export class TodoObject{

public name: string;

public id: number,

public assignedTo:string,

public completed: boolean,

public dueDate:Date

}

In Angular UI I do not require the below two fields

public assignedTo:string,

public dueDate:Date

so can i have an object in Angular UI as below ?

export class TodoObject{

public name: string;

public id: number

public completed: boolean

}

Is it possible to do this in Angular. I know GraphQL has capability for this. Wanted to know if its is possible to achieve this.

Is this possible using Ngrx or other alternative?

Mahdi Shad
  • 1,427
  • 1
  • 14
  • 23
Sam
  • 3
  • 1

1 Answers1

1

You have to manually map the properties.

const frontEndModel = {
  name: backendModel.name,
  id: backendModel.id,
  completed: backendModel.completed
}
timdeschryver
  • 14,415
  • 1
  • 19
  • 32