2017-12-30 8 views
1

ng-inline-svg 패키지를 통해 이온 3.3.0/각도 4.1.2에서 인라인 SVG를 사용하려고합니다. 그것은 'DIV'의 알려진 속성이 아닙니다 때문에인라인 SVG에 바인딩 할 수 없습니다

가 'inlineSVG'에 결합 할 수없는 오류가 발생

import { HttpModule } from '@angular/http'; 
import { InlineSVGModule } from 'ng-inline-svg'; 

@NgModule({ 
    declarations: [AppComponent], 
    imports: [BrowserModule, HttpModule, InlineSVGModule], 
    bootstrap: [AppComponent] 
}) 
class AppModule {} 

템플릿

<div class="icon icon-shop" aria-label="My icon" [inlineSVG]="'../../assets/symbol-defs.svg#icon-shop'"></div> 

그리고 임.

답변

1

Ionic에서 지연 삽입 (Lazy Loading) 때문에 InlineSVGModule 가져 오기를 모든 Pages * .module.ts 파일에 추가해야합니다.

1

app.module에 가져 오기를 배치하는 것이 angular-cli 앱에서 작동하는 경우에도 동일한 문제가 있었지만 webpack에 의해 각도 앱으로 빌드 된 경우에는 그렇지 않습니다.

ng-inline-svg를 사용할 템플릿을 참조하는 구성 요소에 가져 오기를 삽입하여이 문제를 해결했습니다.

관련 문제