我有嵌套对象角2:使对象与嵌套对象到子组件
data: {
nestedData: {
title: 'string'
}
};
我通过属性通过这个数据,以子组件
<child-component [data]="data"></child-component>
儿童分量代码:
import {Component, Input} from 'angular2/core';
@Component({
selector: 'cp-header',
template: '<div>{{ data.nestedData.nestedData }}</div>',
styleUrls: ['app/header/header.component.css']
})
export class ChildComponent {
@Input() data;
}
然后,当我尝试访问模板中的对象属性时,我得到错误;
在你的标记中是'child-compoennt'只是一个错字吗?你有什么组件定义看起来像? – james
@james只是选择器,templateUrl&styleUrls属性 – neilhem
你在孩子中如何以及在哪里访问它? –