I am going through the documentation found here SF Lightning Guide, and during the portion where they create the Contact List view on page 36 they cover the click event using the built in force namespace action: navigateToURL. No matter what I try - $A is null. I have debug enabled, and can see that the line immediately before that call is working fine, and receives the ID of the record for the component, but $A is always coming back null.
I have tried e.force, e.., e.c., etc and cant imagine that this is normal. Everything else has been pretty smooth - but then this came along and I have spent several hours looking for anyone experiencing the same thing. This is a last resort before I scrap both this component and the one above it and start again from scratch.
Error being thrown is:
Uncaught error in markup://ui:click : Cannot read property 'setParams' of null
I am using the exact code from the document at this time. Any ideas to try appreciated.
The code below is being called when a user clicks on a ui:outputText.
The sObjectEvent variable is always null.
I am wondering why it is always null - I assume the force namespace is always available.
gotoRecord : function(component, event, helper) {
// Fire the event to navigate to the contact record
var sObjectEvent = $A.get("e.force:navigateToSObject");
sObjectEvent.setParams({
"recordId": component.get("v.contact.Id"),
"slideDevName": 'related'
})
sObjectEvent.fire();
}
EDIT:
Not able to comment yet - Tried adding <aura:dependency resource="markup://force:navigateToSObject" type="EVENT"/>
to the component and now the error is gone, but nothing happens when you click the text either.
Developer Console is showing that the Event is now being picked up, and that the Params are set properly - $fired$
is true, and the params contains recordId properly now. I will play with moving some controls around and switching it from a ui:outputText
to something else. Thank you for the responses.