使用之间有什么区别吗?
require
来自模板中的节点templateUrl
@Component({
selector: 'hello',
template: require('./home.html'),
})
@Component({
selector: 'hello',
templateUrl: './hello.html',
})
使用template
属性可以在javascript文件中定义html模板。这可以用于小模板。
@Component({
selector: 'hello',
template: `<h1>This is part of template`
})
templateUrl
加载./hello.html
文件使用它代替模板。
@Component({
selector: 'hello',
templateUrl: './hello.html',
})
不同的是使用template
只是小模板和templateUrl
文件。