TIL about @AuraEnabled

When you’re using an <aura:attribute> that is an instance of a custom Apex Class, you need to use the following approach:

  1. Any methods in your class that you want to access from client-side logic must be declared as Static
  2. the @AuraEnabled annotation must be used on those methods as well
  3. Any properties of the class that you wish to access on the Lightning Component must ALSO have the @AuraEnabled annotation

Screen Shot 2016-02-12 at 3.48.21 PM

As for #3…  In my efforts today, I was using <aura:iteration> to create a set of select options that were iterating over a list of custom wrapper classes.  I could not get the values of my custom class object properties to show up on the page, until I realized you have to use this annotation on Properties as well as Methods.

Hopefully this saves you the hour I spent trying to debug my output!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s