• Sharukh sk 3
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi, I am getting below Error for below mentioned codes.

"This page has an error. You might just need to refresh it. Unable to find action 'getStringArray' on the controller of c:ApexComponent Failing descriptor: {c:ApexComponent}"

Apex Class:
public class AttributeTypes {
    public final String[] arrayItems;
    
 @AuraEnabled
    public static List<String> getStringArray() {
        String[] arrayItems = new String[]{ 'red', 'green', 'blue' };
        return arrayItems;
    }

}

ApexComponent.cmp:

<aura:component controller="AttributeTypes">
    <aura:attribute name="favoriteColors" type="String[]" default="cyan, yellow, magenta"/>
    <aura:iteration items="{!v.favoriteColors}" var="s">
        {!s}
    </aura:iteration>
    <lightning:button onclick="{!c.getString}" label="Update"/>
</aura:component>

ApexComponentController.js:

({
    getString : function(component, event) {
    var action = component.get("c.getStringArray");
     action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var stringItems = response.getReturnValue();
                component.set("v.favoriteColors", stringItems);
            }
        });
        $A.enqueueAction(action);
    }
})

ApexApplication.app:

<aura:application >
    <c:ApexComponent/>
</aura:application>
Hi, I am getting below Error for below mentioned codes.

"This page has an error. You might just need to refresh it. Unable to find action 'getStringArray' on the controller of c:ApexComponent Failing descriptor: {c:ApexComponent}"

Apex Class:
public class AttributeTypes {
    public final String[] arrayItems;
    
 @AuraEnabled
    public static List<String> getStringArray() {
        String[] arrayItems = new String[]{ 'red', 'green', 'blue' };
        return arrayItems;
    }

}

ApexComponent.cmp:

<aura:component controller="AttributeTypes">
    <aura:attribute name="favoriteColors" type="String[]" default="cyan, yellow, magenta"/>
    <aura:iteration items="{!v.favoriteColors}" var="s">
        {!s}
    </aura:iteration>
    <lightning:button onclick="{!c.getString}" label="Update"/>
</aura:component>

ApexComponentController.js:

({
    getString : function(component, event) {
    var action = component.get("c.getStringArray");
     action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var stringItems = response.getReturnValue();
                component.set("v.favoriteColors", stringItems);
            }
        });
        $A.enqueueAction(action);
    }
})

ApexApplication.app:

<aura:application >
    <c:ApexComponent/>
</aura:application>