You need to sign in to do that
Don't have an account?
mhitt
Custom lightning component button not navigating to URL
Hi,
I have a custom button in a login flow that needs to navigate to an external website. Below is the code I have for the component and controller, but I think the button needs to redirect to a new tab and open the URL there (the button doesn't navigate the user anywhere).
Component
Controller:
Thanks in advance!
I have a custom button in a login flow that needs to navigate to an external website. Below is the code I have for the component and controller, but I think the button needs to redirect to a new tab and open the URL there (the button doesn't navigate the user anywhere).
Component
<aura:component implements="lightning:availableForFlowScreens" access="global"> <lightning:button variant="brand" label="Find My Closer" title="Find My Closer" onclick="{! c.navigate }" /> </aura:component>
Controller:
({ navigate : function(component, event, helper) { var urlEvent = $A.get("e.force:navigateToURL"); urlEvent.setParams({ "url": 'https://www.google.com' }); urlEvent.fire(); } })Any help is appreciated.
Thanks in advance!
You code is correct but i guess you are testingn from the .app .. Move it into the app using app builder and test it it will work ...
And try to use navigation API rather than the force:navigateToURL
Thank you for the reply. This component is being displayed and used as a login flow (for Community) when the User's cell number is blank in their profile. This button is being tested using that scenario with the intent to redirect the User to another website, however when I click this button it doesn't go anywhere. This should also be a globally accessable page. I'm not exactly sure what changes need to be made to match your suggestion, and I apologize for the novice question but I have little experience with Lightning components 8-). Could you please provide an example?
Thank you!
if you found this answer helpful then please mark it as best answer so it can help others.
Thanks
Akshay