Skip to main content
added 11 characters in body
Source Link
gNerb
  • 9.6k
  • 5
  • 27
  • 58

Build your string in Javascript and just display it to the page as opposed to using the for:each template.

@track animalString;

@wire(getAnimals)
assignAnimals(animals) {
    this.animals = animals;
    
    this.animalString = '';

    this.animals.forEach(functionjoin(item){
        this.animalString += item + ', ';
    },this);

    this.animalString = this.animalString.substring(0, this.anmialString.length()-1');
}

Then:

<span>{!animalString}</span>

Or what ever element/component you want to use to display your string.

Build your string in Javascript and just display it to the page as opposed to using the for:each template.

@track animalString;

@wire(getAnimals)
assignAnimals(animals) {
    this.animals = animals;
    
    this.animalString = '';

    this.animals.forEach(function(item){
        this.animalString += item + ', ';
    },this);

    this.animalString = this.animalString.substring(0, this.anmialString.length()-1);
}

Then:

<span>{!animalString}</span>

Or what ever element/component you want to use to display your string.

Build your string in Javascript and just display it to the page as opposed to using the for:each template.

@track animalString;

@wire(getAnimals)
assignAnimals(animals) {
    this.animals = animals;

    this.animalString = this.animals.join(', ');
}

Then:

<span>{!animalString}</span>

Or what ever element/component you want to use to display your string.

Source Link
gNerb
  • 9.6k
  • 5
  • 27
  • 58

Build your string in Javascript and just display it to the page as opposed to using the for:each template.

@track animalString;

@wire(getAnimals)
assignAnimals(animals) {
    this.animals = animals;
    
    this.animalString = '';

    this.animals.forEach(function(item){
        this.animalString += item + ', ';
    },this);

    this.animalString = this.animalString.substring(0, this.anmialString.length()-1);
}

Then:

<span>{!animalString}</span>

Or what ever element/component you want to use to display your string.