HOW TO USE VALUE PROVIDERS IN SALESFORCE LIGHTNING ?

HOW TO USE VALUE PROVIDERS IN SALESFORCE LIGHTNING ?

VALUE PROVIDERS

In this episode, we have something different to discuss i.e. salesforce lightning value providers.
Let's get started, So value providers are a way to access data.

Value providers encapsulate related value together, similar to how an object encapsulates properties and methods.
The value providers for a component are v(view) and c(controller).

A component's view refers to its attribute set.

A component's controller enables you to wire up event handlers and action for the components. It's where you control your component's logic.

All components have value providers but aren't required to have a controller. Both value providers are created automatically when defined for a component.
In simple words, the salesforce value provider provides information about your browser, location, your device information etc.

Let's understand global value providers.
Global Value Providers :
Global value providers are value and methods that a component can use in the lightning expression.

Here are some global value providers you need to know :

globalId:
It returns the global ID for a component has a unique globalId, which is generated runtime-unique ID of the component instance.

$Browser: It returns information about the hardware and operating system of the browser accessing the application.

$Label: It enables you to access labels stored outside your code.

$Locale: It returns information about the current user's preferred locale.
Now we are more interested to discuss $Browser and $Locale.
So let's see attributes of $Browser :

isAndroid:
It indicates whether the browser is running on an Android device (true) or not (false).

isIOS: It is not available in all implementations. It indicates whether the browser is running on an iOS device (true) or not (false).

isIPhone: It indicates whether the browser is running on the iPhone (true) or not (false).

isWindowsPhone: It indicates whether the browser is running on a windows phone (true) or not (false).
FORM FACTOR ATTRIBUTE :
It returns a Form Factor enum value based on the type of hardware the browser is running on

DESKTOP for a desktop client

PHONE for the phone including a mobile phone with a browser and a          smartphone

TABLET for a tablet client (for which isTablet returns True)
Let's Understand with an example :
Example Lightning Component :
=================================================
<aura:component>
  Browser running on Tablet: {!$Browser.isTablet}
   <br></br>
    Is it running on IPhone: {!$Browser.isIPhone}
    <br></br>
     Is it running on Android: {!$Browser.isAndroid}
     <br></br>
I am Running on : {!$Browser.FormFactor}
</aura:component>
=================================================

Output :
=================================================
Browser running on Tablet: false
Is it running on IPhone: false
Is it running on Android: false
I am Running on DESKTOP
=================================================


Now we have attributes of $Locale global value providers.

$Locale: 
The $Locale global value provider returns information about the current user's preferred locale.

Country: The ISO 3166 representation of the country code based on the language locale.

Currency: The currency symbol.

Timezone: The time zone ID.

NumberFormat: Gives number formatting.
Let's understand with an example :
Example Lightning Component :
=================================================
<aura:component>
  Language : {!$Locale.language}
   <br></br>
   TimeZone : {!$Locale.timezone}
     <br></br>
      Number Format : {!$Locale.NumberFormat}
       <br></br>
        Currency : {!$Locale.Currency}
        <br></br>
</aura:component>
=================================================

Output:

=================================================
Language : en

TimeZone : America / Los-Angeles
Number Format : #, ##0, ###
Currency : $
=================================================


Coool !! In this way, you can use value providers in salesforce lightning component.
In the new episode, we will discuss standard salesforce component and force.com component.

WOHOOO !! YOU HAVE JUST COMPLETED LIGHTNING VALUE PROVIDERS EPISODE
If you like this salesforcekid learning platform please let me know in the Comment section...Also, Share with your salesforce folks wish you 
Happy learning ☁️⚡️ (Learn. Help. Share.)

<< PREVIOUS                                       NEXT >>

HOW TO USE VALUE PROVIDERS IN SALESFORCE LIGHTNING ? HOW TO USE VALUE PROVIDERS IN SALESFORCE LIGHTNING ? Reviewed by on Rating: 5

9 comments:

  1. Anonymous3/12/2020

    Can you please make more episodes on aura lightning components?

    ReplyDelete
  2. Hey There !!

    Please visit our website Blog section for more Episodes...

    Happy Learning 😊

    ReplyDelete
  3. Anonymous3/15/2020

    Ajinkya can you please share your website url?

    ReplyDelete
  4. Sure !!
    Please find the seperate blog section for lightning components.

    LINK :
    https://www.salesforcekid.com/p/blog-page_25.html

    HAPPY LEARNING 😊
    Best Regards,
    AJINKYA DHAS

    ReplyDelete
  5. Anonymous3/16/2020

    Ajinkya I am learning from your blog section but i want to say that can you please make additional tutorial how to insert, update and delete records from salesforce using aura lightning component?

    ReplyDelete
  6. Sure !! I will definitely create this seperate section. thanks for suggestion 😊

    HAPPY LEARNING 😊
    Best Regards,
    AJINKYA DHAS

    ReplyDelete
  7. Hey There,

    As per your request I have added the blog on how to insert records in salesforce lightning component.

    Please find the link attached below :
    https://www.salesforcekid.com/2020/03/create-record-in-salesforce-lightning-component.html

    I hope you like it 😊
    HAPPY LEARNING
    [SalesforceKid]

    ReplyDelete
  8. Anonymous3/24/2020

    Thanks alooot Ajinkya <3
    waiting for your more best tutorials (Y) <3

    ReplyDelete
  9. You are most welcome ! 😊

    Best Regards,
    AJINKYA DHAS

    ReplyDelete

HELP !! SHARE !! SUGGEST !!

Powered by Blogger.