angular - 建立自定义属性
问题描述
我有一个有两个@Inputs 的组件:
@Input() identificador: string;
@Input() descripcion: string;
我将属性名称作为字符串传递,例如(“nombre”)
<ng-template ng-option-tmp let-item="item">
item.{{descripcion}} <br/>
<small class="text-muted">item.{{identificador}}</small>
</ng-template>
我有这个ng-template
,我想在我想要的 ng-template 中构建一个自定义属性:
item.nombre
这是一个示例,因为我希望以我发送的值为基础。
我试过这样做:item.{{descripcion}}
但它不起作用
无论如何我该怎么做?
解决方案
我想将您的财产括在方括号中应该可以:
{{ item[descripcion] }}
因为这就是我们可以在 javascript 中访问动态属性的方式。
推荐阅读
- c# - C#到微控制器的串行通信问题
- vue.js - 在 Vue js 中使用颜色选择器更改字体(文本)颜色
- java - 如何将传感器数据从作为服务器的arduino发送到tomcat上的jsp?
- python - Python 虚拟环境不使用 Cloud9 中的 venv 包
- laravel - 强制松弛登录到队列中
- vb.net - 使用 vb .net 在 microsoft crm 中的电子邮件中添加本地 pdf 附件
- php - 重命名列 Laravel 5.8 后从表中删除数据
- tcp - Mule4 支持 TCP 连接
- xaml - Xamarin 表单中的导航问题
- laravel - 如何在 Lumen 中将文件上传到 AWS s3