“Objek Buat Angular” Kode Jawaban

Objek Buat Angular

export interface Student {
  name: string;
  section: string;
  phoneNumber: string;
}

export interface StudentDetails {
  [key: number]: Student; //Or string instead of number
}

And use it like this:

//Valid
let studentDetails: StudentDetails = {
  1: {
    name: 'Test Person1',
    section: 'Section 1',
    phoneNumber: '12345678'
  }
};

//Valid
studentDetails[2] = {
  name: 'Test Person 2',
  section: 'Section 2',
  phoneNumber: '87654321'
};

//Invalid (properties in UpperCase)
studentDetails[3] = {
  Name: 'Test Person 3',
  Section: 'Section 3',
  PhoneNumber: '52376724'
};

//Valid
let student: Student = studentDetails[2];
JBTheOneAndOnly

suntik suntik membuat sudut

ng g s serviceName
// or
ng generate service serviceName
DevinRC

Jawaban yang mirip dengan “Objek Buat Angular”

Pertanyaan yang mirip dengan “Objek Buat Angular”

Lebih banyak jawaban terkait untuk “Objek Buat Angular” di TypeScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya