How to Use IF condition inside function for only one call and not to use for other call
У меня есть функция ниже, она вызывается дважды, но первое условие «ЕСЛИ» внутри функции должно вызываться только тогда, когда я нажимаю кнопку добавления банка, а не для редактирования банка
private checkNonEnglishCharacterCountries(countryName) {
if(countryName === 'China'){
this.payment.bankAccountName = null;
this.payment.partyAccountNameAlt = this.supplierData.legalName;
}
else if (countryName === 'China') {
this.selectedCountryValidator = '^[\u4E00-\u9FCC]+$';
this.accountBeneficiaryName = 'Simplified Chinese characters - 简化字 ';
this.branchNameLocal = 'Simplified Chinese characters - 简化字 ';
this.bankNameLocal = 'Simplified Chinese characters - 简化字 ';
} else {
this.selectedCountryValidator = '';
this.accountBeneficiaryName = 'Please provide account (Beneficiary) name';
this.branchNameLocal = 'Please provide branch name';
this.bankNameLocal = 'Please provide institution name';
}
this.cdRef.detectChanges();
}
When i add a bank and when i edit a bank it is invoked but my problem is i want the function to be invoked twice but i want the if condition*( if(countryName === 'China'){
this.payment.bankAccountName = null;
this.payment.partyAccountNameAlt = this.supplierData.legalName;
} )*
inside the function to be invoked only on Add Bank
Add Bank function is like this
<button (click)="addBank(payment, 'BANK_ADD')">
Add Bank
</button>
Edit Bank is like this
<img (click)="editSearchPaymentTabInfo('SUPPLIER_BANK_UPDATE', banks, 'BANK_UPDATE')"/>
Я написал вот так но не повезло
private checkNonEnglishCharacterCountries(countryName,textAccessHeader) {
if(textAccessHeader ==="BANK_ADD"){
if(countryName === 'China'){
this.payment.bankAccountName = this.payment.bankAccountName ;
this.payment.partyAccountNameAlt = this.supplierData.legalName;
}
}