1

This is a simple component, not sure what I am missing, this is exactly referred in the docs: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_force_navigateToURL.htm

Component:

<aura:component >
    <aura:handler name="init" action="{!c.navigate}" value="this"/>
</aura:component>

JSController:

({
    navigate : function(component, event, helper) {
        var urlEvent = $A.get("e.force:navigateToURL");
        urlEvent.setParams({
            "url": 'https://www.google.com/maps/place/'
        });
        urlEvent.fire();
    }
})

Error:

This page has an error. You might just need to refresh it. Action failed: c:navigatetoURlcmp$controller$navigate [Cannot read property 'setParams' of undefined] Failing descriptor: {c:navigatetoURlcmp$controller$navigate}

  • where are you viewing this component. Also where did you declared address – Tushar Sharma Oct 13 '17 at 17:54
  • Are you previewing the component through aura:application from developer console? – Rao Oct 13 '17 at 17:54
  • I am just trying without address. It is still should take to the URL right? – Ajay Oct 13 '17 at 17:55
  • did you embed this in an object page or previwing through dev console. If you are previewing through dev console force events are available only inside a LEX environment, your app is a standalone and your component will not work as expected – Rao Oct 13 '17 at 17:57
  • I am testing with standalone app. do I have add this component to LEX page and test? – Ajay Oct 13 '17 at 17:58
0

Did you embed this in an object app builder page or previewing through dev console.

If you are previewing through dev console force events are available only inside a one.app container.

your app is a standalone and the resulting page will be directed to lightning.force.com your force events will not work as expected.

Preview from dev console redirect me to :

https://namespace-dev-ed.lightning.force.com/

As per official docs

This event is handled by the one.app container. It’s supported in Lightning Experience, Salesforce1, and Lightning communities.

0

add the below dependency in the component

<aura:dependency resource="markup://force:navigateToURL" type="EVENT"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.