E
E
exiter12018-03-14 18:39:42
Angular
exiter1, 2018-03-14 18:39:42

Angular How to make a nested object into an object?

Good day to all!
I recently started learning Angular, so don't swear if this seems like a noob question.
I don't understand how to implement the following.
There is a request.ts class:

export class Request {
  id: number;
  date_create: string;
  user_id: number;
  status: number;
  message: string;
}

The object is pulled from the mock:
import { Request } from './request';

export const REQUESTS: Request[] = [
  { id: 11, date_create: '11-11-2017', user_id: 2, status: 1, message: 'Новое сообщение' }

How to make it so that instead of a number at status , a string expression is substituted.
For example, in the requests.component.ts component I add:
statuses = [
       				{id: 0, name: "Отправлена"},
       				{id: 1, name: "На рассмотрении"},
      				{id: 2, name: "Принята"},
       				{id: 3, name: "Отклонена"}
   					];

How to match when outputting to a template?
How to build the architecture for getting and displaying information from the database in Angular with nested objects?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Epifanov, 2018-03-14
@kacheleff

define statusesas an enum structure

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question