我希望能够加载组件HTML特定的脚本文件,这样我就可以在组件HTML本身中放置script
文件引用。但是在页面渲染组件HTML时,我发现内部的script
文件被忽略了。
组件
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: 'test.html'
})
export class AppComponent { }
test.html
<div>
<h1>My First Angular 2 App</h1>
</div>
<script src="test.js"></script>
以下是我尝试过的代码,我已经放置了
test.js
。
点击这里查看 Plunkr
有没有办法在组件或其 HTML 中加载特定的 JavaScript 文件?