When I'm using the Component events config it hooks up the handler with an incorrect this context. I would expect this to reference the App class instance, but it actually references the Home class instance.
@Component({
selector: 'home'
})
@View({
template: "<p>Home</p>",
// Here I'm setting up a 'foo' event
events: {
foo: "foo"
}
})
class HomeComponent {
constructor() {
// See here that I'm adding a property to Home
this.wtf = "wat?";
}
}
@AsModule('AppModule', [HomeComponent])
@Component({
selector: "app"
})
@View({
// Here I'm using the on-foo event and passing a reference to the App's doFoo method
inline: `<home on-foo="doFoo"></home>`
})
class AppComponent {
doFoo() {
// Here is where things fell apart for me and 'this' was not what I expect
console.log(this) // HomeComponent {wtf: "wat?"}, expected an instance of AppComponent
}
}
bootstrap(AppComponent)