hi Satheesh $A.get() method is use in client side controller (javaScript controller) it's use for use Globle value provider in javaScript code. here are some globle valiable like $Browser = returns information about the hardware and operating system of the browser accessing the application. $Label = Use custom labels in Lightning components with the $Label global value provider.
so if you want to use this that gloable value Provider in javaScript code you must use $A.get("$Label.namespace.labelName") OR ({ checkBrowser: function(component) { var device = $A.get("$Browser.formFactor"); alert("You are using a " + device); } })
AND cmp.get() OR cmp.set() = These are useful and common patterns for working with attribute values in JavaScript. use in client side controller (js controller) get the value from component attribute for example <aura:component> <aura:attribute name="firstName" type="string" default="satheesh"/> </aura:component>
for use attribute value in javaScript code you must use cmp.get() ({ getName : function(component, event, helper) { var myName = component.get("firstName"); alert(myName); } }) ------------------------------------------------- i hop it helps you Mark it best answer if it helps you so it make proper solution for others :) Thanks
Component events: to talk to a parent using the capture and bubbling mechanism, like with DOM events. Usually, one component is interested by the event, like an event aggregator.
Application events: to broadcast to other components and not exclusively ancestors. Applications events can talk to many components that can be interested by the event. The broadcast can be boxed to an area of the DOM (everything below a DIV for example).
About $A.getEvt() & cmp.getEvent(): Events have been seriously revamped, and the distinction between Component and Application events has been reduced. However, this rework has not yet been translated into an updated API. I need to remove references to the $A.getEvt() and cmp.getEvent() API because we are still working on a new version of the API. My apologies for the confusion. About value providers: Lightning has various value providers: "v" for attributes, "c" for controller, and "e" for events. Application Event API: Those are obtained from the global (hence $A.get()) event value provider: var evt = $A.get("e.myNamespace:myEvent");
Component Event API: Component must reference events by name, much like an aura:id, and retrieve them from its component (hence cmp.get()) value provider: var evt = cmp.get("e.myEvent");
You would then declare myEvent on the component as: <aura:registerEvent name="myEvent" type="namespace:eventName"/>
Why dow have this API? Declaring events on a component allows other components to call controller methods. You had to declare a handler: <aura:handler name="myEvent" action="{!c.myEventHandler}"/>
That allowed you to call myEventHandler from another component and respect the interface: cmp.get("e.myEvent").fire();
Hope this will help you. If you think you question is answered mark it as best answer. Thanks
hi Satheesh $A.get() method is use in client side controller (javaScript controller) it's use for use Globle value provider in javaScript code. here are some globle valiable like $Browser = returns information about the hardware and operating system of the browser accessing the application. $Label = Use custom labels in Lightning components with the $Label global value provider.
so if you want to use this that gloable value Provider in javaScript code you must use $A.get("$Label.namespace.labelName") OR ({ checkBrowser: function(component) { var device = $A.get("$Browser.formFactor"); alert("You are using a " + device); } })
AND cmp.get() OR cmp.set() = These are useful and common patterns for working with attribute values in JavaScript. use in client side controller (js controller) get the value from component attribute for example <aura:component> <aura:attribute name="firstName" type="string" default="satheesh"/> </aura:component>
for use attribute value in javaScript code you must use cmp.get() ({ getName : function(component, event, helper) { var myName = component.get("firstName"); alert(myName); } }) ------------------------------------------------- i hop it helps you Mark it best answer if it helps you so it make proper solution for others :) Thanks
hi satheesh here is some link related to salesforce lightning try it
http://ccoenraets.github.io/salesforce-lightning-tutorial/create-contactlist-component.html https://teamforcesite.wordpress.com/2016/02/18/creating-a-modal-dialog-box-using-lightning-design-system-lightning-component/ http://coenraets.org/blog/category/lightning-components/ http://blog.jeffdouglas.com/2014/10/14/tutorial-build-your-first-lightning-component/ http://academy.whatfix.com/a-quick-guide-to-create-reusable-salesforce-lightning-component-in-developer-console/ https://meltedwires.com/2015/10/31/salesforce-lightning-lookup-component-v2/ http://bobbuzzard.blogspot.in/2015/12/lightning-component-wrapper-classes.html http://paulbattisson.com/blog/2016/lightning-standard-controller/ http://www.jitendrazaa.com/blog/salesforce/getting-started-with-basics-of-lightning-component/ i hop it helps you to learning lightning Thanks
var myName = component.get("{!v.firstName}"); will not work in the javascript controller. The only time you use the {!v.} annotation is on the component side when you are referencing an attribute.
component.get("v.firstName"); is the correct javascript code to get the component attribute
$A.get() method is use in client side controller (javaScript controller) it's use for use Globle value provider in javaScript code.
here are some globle valiable like
$Browser = returns information about the hardware and operating system of the browser accessing the application.
$Label = Use custom labels in Lightning components with the $Label global value provider.
so if you want to use this that gloable value Provider in javaScript code you must use
$A.get("$Label.namespace.labelName")
OR
({
checkBrowser: function(component) {
var device = $A.get("$Browser.formFactor");
alert("You are using a " + device);
}
})
AND
cmp.get() OR cmp.set() = These are useful and common patterns for working with attribute values in JavaScript.
use in client side controller (js controller) get the value from component attribute
for example
<aura:component>
<aura:attribute name="firstName" type="string" default="satheesh"/>
</aura:component>
for use attribute value in javaScript code you must use cmp.get()
({
getName : function(component, event, helper) {
var myName = component.get("firstName");
alert(myName);
}
})
-------------------------------------------------
i hop it helps you
Mark it best answer if it helps you so it make proper solution for others :)
Thanks
All Answers
Here is the details you need.
Component events: to talk to a parent using the capture and bubbling mechanism, like with DOM events. Usually, one component is interested by the event, like an event aggregator.
Application events: to broadcast to other components and not exclusively ancestors. Applications events can talk to many components that can be interested by the event. The broadcast can be boxed to an area of the DOM (everything below a DIV for example).
About $A.getEvt() & cmp.getEvent():
Events have been seriously revamped, and the distinction between Component and Application events has been reduced. However, this rework has not yet been translated into an updated API.
I need to remove references to the $A.getEvt() and cmp.getEvent() API because we are still working on a new version of the API. My apologies for the confusion.
About value providers:
Lightning has various value providers: "v" for attributes, "c" for controller, and "e" for events.
Application Event API:
Those are obtained from the global (hence $A.get()) event value provider:
var evt = $A.get("e.myNamespace:myEvent");
Component Event API:
Component must reference events by name, much like an aura:id, and retrieve them from its component (hence cmp.get()) value provider:
var evt = cmp.get("e.myEvent");
You would then declare myEvent on the component as:
<aura:registerEvent name="myEvent" type="namespace:eventName"/>
Why dow have this API? Declaring events on a component allows other components to call controller methods. You had to declare a handler:
<aura:handler name="myEvent" action="{!c.myEventHandler}"/>
That allowed you to call myEventHandler from another component and respect the interface:
cmp.get("e.myEvent").fire();
Hope this will help you.
If you think you question is answered mark it as best answer.
Thanks
$A.get() method is use in client side controller (javaScript controller) it's use for use Globle value provider in javaScript code.
here are some globle valiable like
$Browser = returns information about the hardware and operating system of the browser accessing the application.
$Label = Use custom labels in Lightning components with the $Label global value provider.
so if you want to use this that gloable value Provider in javaScript code you must use
$A.get("$Label.namespace.labelName")
OR
({
checkBrowser: function(component) {
var device = $A.get("$Browser.formFactor");
alert("You are using a " + device);
}
})
AND
cmp.get() OR cmp.set() = These are useful and common patterns for working with attribute values in JavaScript.
use in client side controller (js controller) get the value from component attribute
for example
<aura:component>
<aura:attribute name="firstName" type="string" default="satheesh"/>
</aura:component>
for use attribute value in javaScript code you must use cmp.get()
({
getName : function(component, event, helper) {
var myName = component.get("firstName");
alert(myName);
}
})
-------------------------------------------------
i hop it helps you
Mark it best answer if it helps you so it make proper solution for others :)
Thanks
here is some link related to salesforce lightning try it
http://ccoenraets.github.io/salesforce-lightning-tutorial/create-contactlist-component.html
https://teamforcesite.wordpress.com/2016/02/18/creating-a-modal-dialog-box-using-lightning-design-system-lightning-component/
http://coenraets.org/blog/category/lightning-components/
http://blog.jeffdouglas.com/2014/10/14/tutorial-build-your-first-lightning-component/
http://academy.whatfix.com/a-quick-guide-to-create-reusable-salesforce-lightning-component-in-developer-console/
https://meltedwires.com/2015/10/31/salesforce-lightning-lookup-component-v2/
http://bobbuzzard.blogspot.in/2015/12/lightning-component-wrapper-classes.html
http://paulbattisson.com/blog/2016/lightning-standard-controller/
http://www.jitendrazaa.com/blog/salesforce/getting-started-with-basics-of-lightning-component/
i hop it helps you to learning lightning
Thanks
i tried that step. but there is no Packages option in Lightning.
:)
In your code, you have not use the Value Providers. Is that not necessary to use the value providers?
Instead of var myName = component.get("firstName"); should it not be var myName = component.get("v.firstName")
If you use var myName = component.get("firstName"); it will give error.
var myName = component.get("v.firstName"); it is also wrong.
You should use : var myName = component.get("{!v.firstName}"); it will run correctly.
Thanks
var myName = component.get("{!v.firstName}"); will not work in the javascript controller. The only time you use the {!v.} annotation is on the component side when you are referencing an attribute.
component.get("v.firstName"); is the correct javascript code to get the component attribute
<aura:attribute name="Help" type="string" default="Very Helpfull Information"/>
<aura:method name="HelpMethod" action="{!c.HelpFull}" description="Call Controller" />
</aura:component>
({
HelpFull: function(component, event, helper) {
var help= component.get("{!v.Help}");
alert(help);
}
})