I have been testing some features in Lightning recently, but they just don't seem to work, e.g. List view for an object, no matter what I do it never seems to do anything when I click on the button, the gotoList function is executed but does not redirect or show the list, I am testing everything in a DevConsole. Here is a sample code, for the List View, I've been trying to achieve for Account object. Can anyone please explain me why it does not work and how to fix that?
Acc.app
<aura:application implements="force:appHostable">
<ltng:require styles="/resource/slds0121/assets/styles/salesforce-lightning-design-system.min.css"/>
<c:Account />
</aura:application>
Account.cmp
<aura:component controller="LGTN_AccountController">
<ltng:require styles="/resource/slds0121/assets/styles/salesforce-lightning-design-system.min.css"/>
<aura:dependency resource="markup://force:navigateToList" type="EVENT"/>
<aura:dependency resource="markup://force:navigateToSObject" type="EVENT"/>
<ui:button label="List View" press="{!c.gotoList}"/>
</aura:component>
AccountController.js
({
gotoList : function (component, event, helper) {
var action = component.get("c.getListViews");
action.setCallback(this, function(response){
var state = response.getState();
console.log('clicked');
if (state === "SUCCESS") {
var listviews = response.getReturnValue();
var navEvent = $A.get("e.force:navigateToList");
navEvent.setParams({
"listViewId": listviews.Id,
"listViewName": null,
"scope": "Account"
});
navEvent.fire();
}
});
$A.enqueueAction(action);
},
})
LGTN_AccountController.cls
public with sharing class LGTN_AccountController {
@AuraEnabled
public static ListView getListViews(){
return [SELECT Id, Name FROM ListView WHERE SobjectType = 'Account' LIMIT 1].get(0);
}
}