You need to sign in to do that
Don't have an account?
Ankushs@lesforce
Accessing apex list string property in lightning attribute component
Hi
I am able to fetch the apex list of string property in my lightning component through my visualforce page but unable to get values in desired way.
here is my code
apex code snippet as
public class linkforLightning{
@AuraEnabled
public string links {
get;
set;}
public string getlink(){
links = 'apex/TestVFWITHLIGHTNING';
return links;
}
public list<string> getlistOfString(){
list<String> listOfstring = new List<String>();
string s = 'abc';
string s2 = 'XYZ';
listOfstring.add(s);
listOfstring.add(s2);
return listOfstring;
}
}
Component code snippet
<aura:attribute name="contactLevel" type="set" default="test" />
<aura:handler name="init" value="{!this}" action="{!c.onSelectChange}"/>
<div>
<ui:inputSelect aura:id="levels" label="Contact Levels" change="{!c.onSelectChange}">
<aura:iteration items="{!v.contactLevel}" var="level">
<ui:inputSelectOption text="{!level}" label="{!level}"/>
</aura:iteration>
</ui:inputSelect>
</div>
Visualforce code snippet :
$Lightning.use("AnkushTest:onSelectChange", function() {
$Lightning.createComponent("AnkushTest:onSelectPicklist",
{
contactLevel:"{!listOfString}"
},
Output is below :-
[" a" b" c" ," " X" Y" Z" ]" [
I want the out put as
abc, xyz
I need to show it in a picklist field
I am able to fetch the apex list of string property in my lightning component through my visualforce page but unable to get values in desired way.
here is my code
apex code snippet as
public class linkforLightning{
@AuraEnabled
public string links {
get;
set;}
public string getlink(){
links = 'apex/TestVFWITHLIGHTNING';
return links;
}
public list<string> getlistOfString(){
list<String> listOfstring = new List<String>();
string s = 'abc';
string s2 = 'XYZ';
listOfstring.add(s);
listOfstring.add(s2);
return listOfstring;
}
}
Component code snippet
<aura:attribute name="contactLevel" type="set" default="test" />
<aura:handler name="init" value="{!this}" action="{!c.onSelectChange}"/>
<div>
<ui:inputSelect aura:id="levels" label="Contact Levels" change="{!c.onSelectChange}">
<aura:iteration items="{!v.contactLevel}" var="level">
<ui:inputSelectOption text="{!level}" label="{!level}"/>
</aura:iteration>
</ui:inputSelect>
</div>
Visualforce code snippet :
$Lightning.use("AnkushTest:onSelectChange", function() {
$Lightning.createComponent("AnkushTest:onSelectPicklist",
{
contactLevel:"{!listOfString}"
},
Output is below :-
[" a" b" c" ," " X" Y" Z" ]" [
I want the out put as
abc, xyz
I need to show it in a picklist field