I want to show in the UI dynamically the current page label...

so i try something like this in Component section: i want to show the v.pages[currentPage].Label__c value... But i get message on save expecting a positive integer, found '+' at column 9 of expression: v.Pages[+"!v.currentPage"+].Label__c: Source

Code snippet below...

<aura:attribute name="pages" type="Page__c[]" />
<aura:attribute name="currentPage" type="Integer" />
    <span class="slds-page-header__title slds-truncate" title="{!v.currentPage}"> 

Any ideas ?


You can not access the array index dynamically in HTML.

As an alternative, you can set the current page label in js


    <aura:attribute name="pages" type="Page__c[]" />
    <aura:attribute name="currentPage" type="Integer" default="0" />
    <aura:attribute name="currentPageLabel" type="String" />

    <aura:handler name="change" value="{!v.currentPage}" action={!c.setLabel}" />



setLabel: function(component) {
    const pages= component.get('v.pages');
    const currentPage= component.get('v.currentPage');

    component.set('v.currentPageLabel', pages[currentPage].Label__c);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.