[SOLVED] It possible to make this JavaScript to Typescript?

this code as a .js I want this to work on .ts

document.getElementById(‘container’).appendChild(

slides.reduce((fragment, svg, i) => {
    const span = document.createElement('span');
    span.innerHTML = `
                <p>${slideNames[i]}</p>
                <div>${svg}</div>
            `;

    fragment.appendChild(span);
    return fragment;
}, document.createDocumentFragment())

);

Anyone can help me to solve this problem?
I have no idea to make it.
Thanks.

In general, you want to avoid calls to document if you are using a framework like Angular. It would be better to figure out how to do want you want with Angular. Typescript isn’t really the issue here.

2 Likes

Angular had ngFor to solve this. Check out structural directives on angular.io