2017-05-24 1 views
0

app.component와 같은 디렉토리에 SVG 파일이 있습니다.각도 재질 404 오류를주는 SVG 아이콘

<md-icon svgIcon="thumbs-up"></md-icon> 

타이프 스크립트 : 내가 개발 서버에서 실행할 경우

import {Component} from '@angular/core'; 
import {DomSanitizer} from '@angular/platform-browser'; 
import {MdIconRegistry} from '@angular/material'; 

@Component({ 
    selector: 'icon-svg-example', 
    templateUrl: './icon-svg-example.html',}) 

export class IconSvgExample { 
    constructor(iconRegistry: MdIconRegistry, sanitizer: DomSanitizer) { 
    iconRegistry.addSvgIcon(
     'thumbs-up', 
     sanitizer.bypassSecurityTrustResourceUrl('assets/img/examples/thumbup-icon.svg')); 

이 아이콘이 표시되지 않습니다를 내 HTML에서 아이콘을 사용하기위한 Angular Material 예를 따라? 난 그냥 콘솔에서이 오류 메시지가 :

GET http://localhost:4200/thumbs-up.svg 404 (Not Found) 
Error retrieving icon: undefined 
+2

제공하는 경로이므로'assets/img/examples' 폴더에 넣으십시오. – trichetriche

+0

@trichetriche 감사합니다. 경로에 오류가있었습니다. 코멘트에서 답을 얻은 답을 어떻게 표시합니까? – Nicholas

+0

나는 당신이 upvote 수있는 답변을 게시하거나 그냥 왼쪽에 의견을 upvote 수 있습니다. – trichetriche

답변

2

코멘트와 함께 해결로 당신은 그것을 표시 할 수 없습니다 때문에 :이 경로이기 때문에,

은 자산/IMG/예 폴더에 넣어보십시오 당신 제공