首页 > 解决方案 > 将外部 javascript 包含到 Angular 中

问题描述

我试图将外部 javascript 和 html 包含到我的 Angular 应用程序中。

这是在 jsfiddle 中工作的作者教程

<!-- header source -->
<script src="https://www.givengine.org/bower_components/webcomponentsjs/webcomponents-loader.js"></script> 
<link rel="import" href="https://www.givengine.org/components/chart-controller/chart-controller.html">

<!-- embed the browser in the web page -->
<chart-controller 
  title-text="A 2-minute starter of building a genome browser with GIVE" 
  ref="hg19" 
  num-of-subs="2" 
  coordinate='["chr18:19140000-19450000", "chr18:19140000-19450000"]'
  group-id-list='["genes", "CHi-C_promoter"]'
></chart-controller>

所以我根据我的角度应用程序做了它,将脚本引用添加到 index.html

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>EpiMiner</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  
  <script src="http://localhost:40080/bower_components/webcomponentsjs/webcomponents-loader.js"></script> 
  <link rel="import" href="http://localhost:40080/components/chart-controller/chart-controller.html">
  <link rel="icon" type="image/x-icon" href="favicon.ico">

</head>
<body>
  <app-root></app-root>
</body>
</html>

app.component.html

<chart-controller 
  title-text="A 2-minute starter of building a genome browser with GIVE" 
  ref="hg19" 
  num-of-subs="2" 
  coordinate='["chr18:19140000-19450000", "chr18:19140000-19450000"]'
  group-id-list='["genes", "CHi-C_promoter"]'
></chart-controller>

但我得到一个“图表控制器不是已知元素”错误。没有太多的角度经验。建议表示赞赏。谢谢

标签: javascriptangular

解决方案


推荐阅读