child.component.ts
я есть дочерний компонент, который выглядит следующим образом
Дочерний компонент
@Component({
selector: 'child-component',
//TemplateUrl, Styles and Providers
})
export Class ChildComponent implements OnInit{
@Input()
arrayToGet; //An array that I want to pass from Parent to child
ngOnInit(){
console.log('The Array I got is ', this.arrayToGet); //Undefined, Tried even with setTimeout
}
//A bunch of methods to work with the array I get
}
Родительский компонент
@Component({
selector: 'parent-component',
template: '<div>
<child-component [arrayToGet]="models"></child-component>
</div>',
//A bunch of Styles and Providers
})
export class ParentComponent{
models;
constructor(......){}
ngOnInit(){
//Get an array from a service assign to this.models;
}
}
Проблема в том, что я не могу выполнять какие-либо операции наarrayToGet
внутри моегоChildComponent
, Однако я могу использовать свойства наarrayToGet
внутри моегоChildComponent
HTML.
есть идеи?