8

I am following the Trailhead "Create a Lightning Component" tutorial and I have reached the part where I have build the controller (Apex) and I am attempting to set the aura:component controller.

My Developer org has a namespace prefix set due to an earlier tutorial and I think it is conflicting. When I try and set the controller:

<aura:component controller="MyContactListController">

</aura:component>

I receive the following error:

Failed to save undefined: No CONTROLLER named apex://devprefix.MyContactListController found: Source

any idea why my controller is not being accessed under the namespace prefix? In case you are wondering I am posting the contents of the apex class below:

public class MyContactListController {
    @AuraEnabled
    public static List<Contact> getContacts() {
        return [Select Id, Name, Email, Title, Phone From Contact];
    }
}

Any help would be appreciated.

Thanks in advance!

2
  • If you are doing this in the developer console, does your MyContactListController file name tab have a .apxc suffix or a .js suffix?
    – martin
    Commented Sep 18, 2015 at 1:56
  • It has an apxc extension Commented Sep 18, 2015 at 2:00

1 Answer 1

13

I was able to recreate the issue, and although I don't know what is causing it, I was able to get past it by changing the name of the apex class:

public class MyContactListControllers {
    @AuraEnabled
    public static List<Contact> getContacts() {
        return [Select Id, Name, Email, Title, Phone From Contact];
    }
}

and then making the corresponding change in the component:

<aura:component controller="MyContactListControllers">

</aura:component>

Oddly after doing that, I could revert them back to their previous names and they would save without issue.

1
  • Same Happened with me.I guess the issue was the space after the class name.After i removed the space after the class name in my apex controller, the error was gone. Puff!!!!
    – Samir
    Commented Oct 4, 2016 at 11:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .