I am having trouble getting angular2 to pass input into a child component. Within the child component, the object is always undefined. Here is my code.
My markup in the parent component
<peoplesearchlist [people]="peopleSearchData"></peoplesearchlist>
The child component
import {Component, View, Input} from 'angular2/angular2';
@Component({
selector: 'peoplesearchlist',
inputs: ['people']
})
@View({
templateUrl: './directory/peopleSearchList.html'
})
export class PeopleSearchList {
constructor() {
console.log('People-Search-List:' + this.people);
}
}
Abbreviated Parent Component
import {Component, View, Input, bootstrap} from 'angular2/angular2';
import {Http, Headers} from 'angular2/http';
import {PeopleSearchBar} from './peopleSearchBar';
import {PeopleSearchList} from './peopleSearchList';
@Component({
selector: "directory-people-search"
})
@View({
templateUrl: "./directory/peopleSearch.html",
directives: [PeopleSearchBar, PeopleSearchList]
})
export class PeopleSearch
{
constructor(http: Http) {
this.searchString = '';
this.http = http;
this.peopleSearchData = {
faculty: [],
students: [],
retirees: []
};
console.log('People-Search' + this.peopleSearchData);
}
}
If I look in my console, I see first the log from the parent component with the object, then the log from the child component as undefined. I've tried using @Input people, but have the same behavior.
I am using ES6 with traceur. I have looked at this issue and could not resolve my issue: Angular 2 Component @Input not working