Looking for help with passing data to a child component? Check out this Plunker:
http://plnkr.co/edit/G1EgZ6kQh9rMk3MMtRwA?p=preview
@Component({
selector: 'my-app',
template: `
<input #x />
<br />
<child [value]="variable"></child>
<button (click)='test(x.value)'>Button</button>
`,
directives: [ ChildComponent ]
})
export class AppComponent {
public variable;
test (x:any){
console.log('test',x);
this.variable = x;
}
}
This is my primary component where I update the variable value.
I'm trying to assign an input's value to a variable, then pass that variable value as an input to a child component so it can receive the updated value. However, it's not working as expected. Can someone help me spot my mistake?