1
Hello everyone, I have a Component with 1266 lines, due to its large volume of methods, I need to separate these methods to facilitate a future maintenance, only problem in this is that I have local variables, and these methods most consume these variables, how I can separate these methods without having to break all my code ?
I tried to create a Heldp Component, and my Main Component would pass as parameters .
EX -- Component in the same directory "Myrdesp"
//ComponentPrincipal
export class ExpenseReportsFormComponent implements OnInit {
help: any;
help = ComponentHelp
this.help.populateField(item,this) // this mandaria todo dados do meu component
}
//component que teria metodos
export class ComponentHelp{
//metodo
populateField(item:any,component:any){
// funlçoes do meotdo
component.form['controls']['itens']['controls'][i]['controls'].id.setValue(item.id);
component.form['controls']['itens']['controls'][i]['controls'].currencyAlias.setValue(item.currencyAlias);
component.form['controls']['itens']['controls'][i]['controls'].product.setValue(item.productId);
component.form['controls']['itens']['controls'][i]['controls'].currency.setValue(item.currencyId);
component.form['controls']['itens']['controls'][i]['controls'].productIcon.setValue(item.productIcon);
component.form['controls']['itens']['controls'][i]['controls'].value.setValue(item.value);
}
}
But he gives me a mistake saying that I do not exist in Componenthelp
Could someone tell me why I can’t do this process? And what’s the best way ?