I have this class:
export class Cliente {
public idCliente?: string;
public nome?: string;
public email?: string;
public imgCliente?: string;
public dataCadastro?: any;
public dtUltimoContato?: any;
public cpfCnpj?: number;
public identidade?: string;
public telefone?: string;
public address?: Address;
public pesquisa?: string[];
public sexo?: string;
}
I want to get some of these attributes(nome, cpfCnpj, telefone, email) and create an array and populate the "pesquisa" attribute.
For that, I am using this to transform "nome" into an array:
nome.toLowerCase().split(' ', )
I wish to create some function inside the class, so when saving the object in database for example, it already saves the field "pesquisa" as an array with the mentioned data.
How would I do that?
If there is a better idea, it is very welcome also.