This discussion은 typescript 2
에 외부 클래스 인 css
파일을 내 클래스에서 사용할 문자열로 가져올 수 있음을 나타냅니다.Typescript : .ts 파일을 원시 문자열로 가져 오는 방법
내 typescript 구성 요소로 HTML을 가져 오기 위해이 응용 프로그램을 사용하여 두 개의 개별 요청 대신에 & 구성 요소를 가져 오는 HTTP 요청을 하나 만들려고합니다. 나는 시도했다 :
typings.d.ts
declare module "*!text" {
const value: any;
export default value;
}
app.component.ts
import htmlTemplate from './app.component.html!text';
...
constructor(){console.log(htmlTemplate)}
타이프 스크립트 컴파일러는 오류를 발생하지합니다. 나는 응용 프로그램을 실행할 때, 그것은 http://localhost/text
를 요청하고 404
가 나는 또한 시도했다
found`하지받은 후 충돌 : typings.d.ts
declare module "*.html" {
const value: any;
export default value;
}
app.component. TS
import htmlTemplate from './app.component.html';
...
constructor(){console.log(htmlTemplate)}
는 다시 오류는 컴파일시 발생하지 않고 응용 프로그램은 http://localhost/app.component.html.js
및 이러다 요청 응답을 404 not found
응답을받은 후 유골.
템플릿은 .ts
파일과 같은 폴더에 app.component.html
입니다. 나는 typescript 2.0.2
을 실행 중입니다. .html
템플릿과 .css
스타일 시트를 문자열로 가져 오려면 어떻게해야합니까? 여기