You need to sign in to do that
Don't have an account?

How to call apex method in LWC html
@AuraEnabled public static String getContactPhone(){ if(String.isNotBlank(lstAcc[0].Customer_Care_Phone__c)){ return lstAcc[0].Customer_Care_Phone__c; }else if(String.isNotBlank(lstAcc[0].Customer_Care_Phone_FZ__c)){ return lstAcc[0].Customer_Care_Phone_FZ__c; } }I wanted to call this return string in LWC
You can try using the below snippet in the js controller of the lwc component to call the apex method.
You won't be able to call the apex method from the HTML file of the LWC component instead you need to make a call from the controller.
For more details, you can try checking this link: https://www.sfdcpoint.com/salesforce/call-apex-methods-in-lightning-web-components/
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
my apex controller method is returning a string
i want show that string in LWc
As mentioned in the link -https://salesforce.stackexchange.com/questions/281096/lwc-return-string-from-apex-just-shows-object-object the attribute with wire annotation has two parts and it has two parts data and error and you can try checking this template once.