Inserting HTML for Slides from String Variable


#1

I have code in my ts file that puts most of the html code for slides I have into a string(I need to do this because I have to traverse through an object recursively and I’m layering images on svg’s and need to transform them). So this function would generate a large string that looks like

<ion-slides>
  <ion-slide>
    <svg ...>layers of images</svg>
  </ion-slide>
  <ion-slide>
    <svg ...>layers of images</svg>
  </ion-slide>
  <ion-slide>
    <svg ...>layers of images</svg>
  </ion-slide>
</ion-slides>

When I paste this code into the html file, the slides work perfectly, but when I put the string into a div and setting its innerHTML like so

  ionViewDidLoad(){
    document.getElementById('div').innerHTML = this.htmlstring;
  }

the slides appear as a list of images instead of as slides.

Is there any way to fix this?


#2

Maybe you should start using angular to do it ? :smiley: