[英]how can import template.html in typescript
i want to include template in my typescript how can do that?? 我想在我的打字稿中包含模板怎么做?
var template = import './template.html'
i use web pack and bundle all file into one javascript file. 我使用Web包并将所有文件捆绑到一个javascript文件中。
i use angularjs (v1) and want to build component base project using typescript gulp and webpack and now i use this code. 我使用angularjs(v1)并希望使用typescript gulp和webpack构建组件基础项目,现在我使用此代码。
declare var require:any;
import './cart.template.html';
import {cartController} from './cart.controller'
export var cartComponent = {
template: require('./cart.template.html'),
controller:cartController
}
is there any better solution for doing this??? 这有什么更好的解决方案???
first, declare an HTML module like this: 首先,声明一个这样的HTML模块:
declare module "*.html" {
const content: string;
export default content;
}
then, use it: 然后,使用它:
import * as template from "template.html";
@Component({
selector: 'home',
directives: [RouterLink],
template: template
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.