angular - 有没有办法将输入字符串中的锚标记传递给标签
问题描述
我有一个用于复选框的自定义类,其中标签和输入与类一起定义。
我在另一个类中使用该组件,我需要传递一个包含链接的标签,例如:请接受继续。那么是否可以使用包含链接的上述字符串传递标签?
customCheckbox.component.ts
<div class="form-group" [formGroup]="checkboxForm">
<label class="checkboxContainer">
{{ label }} <input id="{{ id }}" type="checkbox"
[formControlName]="checkboxFormName" />
<span class="checkmark"></span>
</label>
</div>
用法
<custom-checkbox
id="_id"
[checkboxForm]="checkboxForm"
[nameOfControl]="checkboxFormName "
label="{'Please accept the <a>terms and condition </a> .'" >
</custom-checkbox>
所以需要这种类型的标签。
解决方案
您可以将标签的文本传递到标签的 innerHTML 中。像这样:
label = 'This is normal,but <a href="https://www.google.com"> this is link</a>'
<label [innerHTML]="label"></label>
推荐阅读
- ios - 为什么我会收到上传错误 ITMS-90680 和 ITMS-90171
- apache - .htaccess rewrite - filename.html to /?c=filename
- javascript - 使用for循环-AngularJS推送方法()后无法显示新的空数组
- java - 在R中组合/排列不同数据帧/文件的多个单元格
- json - 如何解析 Unmarshaled 结构中的引用
- docker - Docker :: 如何查看由 Docker for Mac 制作的图像中的包装?
- path - 网络共享脚本 - 自动检查驱动器号和路径
- c# - 需要转换代码以选择随机行并显示
- axios - 如果 axios 请求失败,error.response 未定义
- excel - 根据单元格值从一个工作表复制行并粘贴到另一个工作表到下一个可用行