angular - 如何访问由调用组件以角度绑定的对象的属性?
问题描述
组件定义:
...
...= {'a':1}
```
在模板中:
...
{{test|json}}
{{test.a}}
...
输出:
{ "a": 1 }
一切都是对的。但我想从另一个组件绑定属性测试:
组件定义:
...
@Input()
test = {}
...
在根组件/模板中:
...
<test-component [test]="{'a':1}"></test-component>
...
在模板中:
...
{{test|json}}
...
输出:
{ "a": 1 }
在模板中:
...
{{test|json}}
{{test.a}}
...
输出:
**ERROR: error TS2339: Property 'a' does not exist on type '{}'**
为什么该属性a
无法访问,我该如何解决?
解决方案
推荐阅读
- r - 来自两个数据帧的两列的条件 setdiff(全对全),具有用于匹配的数字范围
- ontology - 将 JSON-LD 本体转换为 HTML 文档的工具
- excel - 如何使用公式(例如:索引,间接函数)获取对不在范围内的单元格列表(Excel)的引用?
- python-3.x - 即使在运行“Facebook AI 性能评估平台”时它已经存在,也没有名为“请求”的模块
- django - 如何在 Django 模型中执行乘法?
- php - 将 PHP 5.6 新闻脚本转换为 7.2
- html - 从链接的一部分中删除下划线
- php - 在新选项卡中打开 pdf 文件
- javascript - 从列(SQL-DataTable)中提取重复的日期和时间并将它们显示为 MVC Web App 上的列标题
- python-3.x - 为什么 select.select 告诉我它不可读