Angular 2 version: rc.1
I have a parent and a child component.
I have an object called Options in the parent component containing strings and functions I want to pass to the child component using @Input. The strings that I pass work fine and as expected, but I am having trouble passing a function.
Here is some of the code relating to my problem.
parent.component.ts
constructor(private service: Service) {}
//getResults is a function in service that takes two arguments
public Options = {
placeholder: "Enter Value",
getReq: function(foo, bar) {
return this.service.getResults(foo, bar)
},
parent.component.html
<child placeholder="{{Options.placeholder}}" getReq="{{Options.getReq}}"><child>
child.component.ts
@Input() placeholder: String;
@Input() getReq: Function;
searchResults() {
return this.getReq(foo, bar)
.subscribe(
data => this.Results$ = data
)
}
The error I get is "this.getReq is not a function"
Any ideas?