Javascript 如何在typescript中导入template.html
我想在我的打字脚本中包含模板,怎么做Javascript 如何在typescript中导入template.html,javascript,angularjs,typescript,webpack,Javascript,Angularjs,Typescript,Webpack,我想在我的打字脚本中包含模板,怎么做 var template = import './template.html' 我使用web包并将所有文件捆绑到一个javascript文件中 我使用angularjs(v1)并希望使用typescript gulp和webpack构建组件库项目,现在我使用这段代码 declare var require:any; import './cart.template.html'; import {cartController} from './cart.co
var template = import './template.html'
我使用web包并将所有文件捆绑到一个javascript文件中
我使用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
}
有更好的解决方案吗?首先,声明如下HTML模块:
declare module "*.html" {
const content: string;
export default content;
}
然后,使用它:
import * as template from "template.html";
@Component({
selector: 'home',
directives: [RouterLink],
template: template
})
出于某种原因,它抱怨找不到module template.html。但是需要完美地工作。你知道怎么用打字脚本吗?