【问题标题】:Adding multiple HTML Blocks in a single html file using angular2 and using their elements between each other使用 angular2 在单个 html 文件中添加多个 HTML 块并在彼此之间使用它们的元素
【发布时间】:2017-12-02 19:20:40
【问题描述】:

假设我有一个 template.html 和 2 个子模板(sub-template1.html 和 sub-template2.html),我如何让它们在 template.html 中呈现,并使用类和 ID,以及 sub-template2.html 中的 sub-template1.html 中的其他 DOM 相关变量。

例如:sub-template1.html 有一个视频,我需要在 sub-template2.html 中访问它的当前时间

<!--template.html-->
<html>
<head>
<title></title
</head>
<body>
<!--- sub-template1.html -->
<br>
<!--- sub-template2.html -->
</body>
</html>


<!-- sub-template1.html -->
<div>
<video></video>
</div>


<!-- sub-template2.html -->
<div>
<h1> <!-- current time from video in sub-template1.html --></h1>
</div>

【问题讨论】:

    标签: javascript jquery html angular2-template


    【解决方案1】:

    您需要创建一个服务来在两个控制器之间传递数据。请参考以下链接

    Angular 2 Sibling Component Communication

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-25
      • 2013-02-12
      • 2018-02-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多