Stack Overflow Asked by Harry_C on December 11, 2021
I am pretty new to Angular and how to use oop in this context. I have used a user interface when register a new user.
export interface User {
firstName: string;
lastName: string;
email: string;
password: string;
}
When I edit that user there needs more fields (role, id etc).
export interface User {
_id: string;
role: string;
firstName: string;
lastName: string;
email: string;
password: string;
date: string;
}
Shall I use two interfaces – one for registering and one for editing or should I use a class with required fields and non-required? What is best practice here? Please advise!
You should create interface with optional and not-optional properties like below:
export interface User {
id: number;
name?: string; // optional parameter
}
It will be better approach in your case
Answered by Pritesh on December 11, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP