javascript - angular4 import html file -


i want save test.svg in component variable 'a' or svgicon.component.html.
so, create svgicon.component.ts file. not working. should do?

svgicon.component.ts

import { component, oninit } '@angular/core';  import { svgs } './svg/test.svg';    @component({    selector: 'app-svgicon',    templateurl: './svgicon.component.html',    styleurls: ['./svgicon.component.css']  })  export class svgiconcomponent implements oninit {    public a: string = svgs;    constructor() { }      ngoninit() {    }    }

test.svg

<svg version="1.1" width="10" height="14" viewbox="0 0 10 14"> <path fill="#d4d4d4" d="m5,0.024c-2.761,0-5,2.269-5,5.069c0,1.139,0.37,2.19,0.996,3.036l-0.02,0.039l2.664,3.856l1.349,1.953 l1.339-1.953l2.62-3.82c9.607,7.345,10,6.265,10,5.093c10,2.293,7.761,0.024,5,0.024z m5,7.024c-1.105,0-2-0.895-2-2s0.895-2,2-2 s2,0.895,2,2s6.105,7.024,5,7.024z" /> </svg>

folder directory

enter image description here

<div [innerhtml]="a"></div> 

or (depending on content of a)

<svg [innerhtml]="a"></svg> 

you might need apply sanitizer convince angular it's safe add content of a. more details see in rc.1 styles can't added using binding syntax


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -