html - Angular6 创建可重用的 html 人工制品
问题描述
我对角度很陌生,所以请耐心等待。
我想创建一组 ui 元素。可以说,我有一个部分是这样的:
<section>
<h2 class="section-title">Title</h2>
<... html to make section collapsible .../>
<div class="section-body">
content goes here
</div>
</section>
现在每次我想用这个,我必须复制粘贴它......
我是否有可能为此创建自己的模板?
<my-section title="Some Title" collapsible="true">
content goes here
</my-section>
解决方案
请提供您的代码逻辑。
但我猜你正在寻找一些数据的迭代,而这里示例中的数据是items
<section>
<h2 class="section-title">Title</h2>
<... html to make section collapsible .../>
<div class="section-body" *ngFor="item of items">
{{ item }}
</div>
</section>
推荐阅读
- c# - 动态数量的视图应分别绑定到相应的视图模型
- python - Django 翻译不适用于 DE 语言
- docker - 如何将执行时间放入容器?
- java - 将 Hashmap 拆分为两个较小的映射
- python - 如何使用 python 在 pandas 中查找具有逻辑的索引?
- javascript - 在 react-app 中加载 bundle.js 失败。该应用程序无法按预期工作
- python - 为什么使用括号时 re.findalll 和 re.finditer 的输出不同?
- android - 在 Android gradle 构建中排除资源文件夹中的文件
- python - 无法通过 python 记录器打印 pexpect 响应
- c++ - ubuntu 18.04 中的 Clion cmake