angular-svg-icon icon indicating copy to clipboard operation
angular-svg-icon copied to clipboard

Is it possible to initialize svg-icons in typescript?

Open usamauzi opened this issue 5 years ago • 5 comments

Hi, I am trying to initialize this in a typescript file using document.createElement to display in a map webapp as an overlay (openlayers).

let jtiImageElement = document.createElement('svg-icon'); jtiImageElement.setAttribute('src', 'assets/icons/jtis/1A.svg'); //jtiImageElement.setAttribute([stretch],"true"); //jtiImageElement['src'] =assets/icons/jtis/1A.svg; jtiImageElement['[svgStyle]'] = "{width.px:'100', height.px:'100'}";

ive tried initializing it this way, there is a svg-icon in the DOM but there is no image and the dimensions are 0x0. the url of the svg is also working.

usamauzi avatar Jul 21 '20 07:07 usamauzi

This svg-icon Angular component wasn't design for this type of use. Have you tired using the Angular approach by using a dynamic component loader?

czeckd avatar Jul 21 '20 09:07 czeckd

Actually, this part of the code is being used in the ngoninit method. I am essentially trying to add some svg photos on a map using openlayers, and want to manipulate them to flash borders etc ( animate ).

usamauzi avatar Jul 22 '20 03:07 usamauzi

What version of Angular are you using?

czeckd avatar Jul 22 '20 04:07 czeckd

Annotation 2020-07-22 143518

usamauzi avatar Jul 22 '20 06:07 usamauzi

Thanks. I've never attempted to use the component in the way that you're using it with document.createElement. If you want to provide code for a full reproducer, I can take a look some more at it. I tried to come up with a workable example, but no luck on my part.

czeckd avatar Jul 22 '20 07:07 czeckd