How to access apex class property in lightning component

Lightning Component

Sharing is caring!

Prerequisites : basic understanding of Lightning Component and Apex programming

classController.apxc

  • First we create  component controller class .
  • It’s have 3 {get ;set;}  property variable on line number 5,6 and 7, with @AuraEnabled annotation .
  • The @AuraEnabled annotation enables client- and server-side access to an apex controller method and controller property. Providing this annotation makes your methods and properties available to your Lightning components.
  • In this controller we have a single method which return type is class type .

Test.cmp

 

    • In our test component we have a aura:attribute which type is class Type.
    • On the component initialize  call initClass() method and set return value in aura:attribute.
    • And finally access class property in component by {! v.objClassController.PropertyName }

TestController.js

 

TestApp.app

output-:

apex class properties
Like our facebook page for new post updates.?

Sharing is caring!

(Visited 4,396 times, 16 visits today)

2 comments

Leave a Reply