1

I have a progress indicator in below playground with 2 buttons next and previous but when I click on next button the value of step changes but the path value doesn't change, can anyone please look and suggest what am I missing.

Playground

  • 1
    I'm pretty sure people would want you to post some code here, just in case the playground link goes dead... – Caspar Harmer Dec 10 '19 at 7:15
3

lightning-progress-indicator takes a string for the current-step... so all you need to do is call toString() on your current step.

Playground link

Here:

@track progressStep = 1;
@track progressStepString = "1";

nextPage () {
    this.progressStep++;
    this.progressStepString = this.progressStep.toString();
}
prevPage () {
    this.progressStep--;
    this.progressStepString = this.progressStep.toString();
}
  • Can you please give Playground Link so that we can understand more – Sahil Malhotra Dec 10 '19 at 7:51
2

Check the Playground LINK.

Its working as you want. You needed to iterate lightning-progress-step & increment.

1

This is because current-step takes value as string , hence either iterating or hardcoding value as passing as String will solve the purpose

@Mohit: Thanks but if i case the requirement is to hard code it we may use following

html

<template>

    {step}

    <lightning-progress-indicator current-step={mystep} type="path" variant="base">
        <lightning-progress-step label="Contacted" value="1"></lightning-progress-step>
        <lightning-progress-step label="Open" value="2"></lightning-progress-step>
        <lightning-progress-step label="Unqualified" value="3"></lightning-progress-step>
    </lightning-progress-indicator>

    <lightning-button label={prevLabel} class="slds-float_left slds-p-left_small" onclick={prevPage} icon-name="utility:back"
     variant="brand">
    </lightning-button>

    <lightning-button label={nextLabel} class="slds-float_right slds-p-right_small" onclick={nextPage} variant="brand" icon-position="right"
     icon-name="utility:forward">
    </lightning-button>

</template>

js

import { LightningElement, track, api } from 'lwc';

export default class App extends LightningElement {

    @track step = 1;
    @track mystep =1;

    nextPage = () => { this.showSpinner = true; this.step++;this.mystep = this.step.toString(); this.showSpinner = false; }
    prevPage = () => { this.step--;this.mystep = this.step.toString(); }
}

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.