I'm making an angular project using asp.net for the back-end. So I want to make use of data transfer objects in angular but I'm having problems replicating the navigation properties. Is there anyway to do this?
My DTOs so far:
import { DocumentsDto } from './DocumentsDto';
export class CaseFilesDto {
idCaseFile: number;
CaseFileName: string;
CreationDate: Date;
CaseFileOwner: string;
AmountOfDocuments: number;
Document: DocumentsDto[];
public CaseFilesDto() {
this.Document = new DocumentsDto[];
}
}
import { CaseFilesDto } from './CaseFilesDto';
export class DocumentsDto {
idDocument: number;
idCaseFile: number;
DocumentName: string;
CreationDate: Date;
CaseFile: CaseFilesDto;
}
The problem here is in the line where it puts:
this.Document = new DocumentsDto[];
Using tslint on visual studio code I get that the error is that documentsDto misses the include property. But I can't find such thing.
Thank you!
Regards.
You need to change the line to
this.Document = [];
In javascript and typescript you can create a new array just like that. You could even simplify it a bit like this.
export class CaseFilesDto {
idCaseFile: number;
CaseFileName: string;
CreationDate: Date;
CaseFileOwner: string;
AmountOfDocuments: number;
// Initialize the value
Document: DocumentsDto[] = [];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With