-
I use your lib to bind HostBinding to observables like describes here: https://indepth.dev/posts/1429/making-hostbinding-work-with-observables So basically I do something like this: @Component({
selector: 'app-layout',
templateUrl: './layout.component.html',
styleUrls: ['./layout.component.scss'],
})
export class LayoutComponent {
@HostBinding('$.class.collapsed')
@HostListener('$.class.collapsed')
readonly collapsed = this.ui.sideNav;
constructor(private ui: UiService) {}
... It's working great. But our test are now broken (all components which are using this layout component). I'll get the following error (when running Jest):
I have no idea how this could happen or how to fix this. Any hints? Best regards, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Unfortunately for now it's not possible without hacks. You can remove @Component({
selector: 'app-layout',
templateUrl: './layout.component.html',
styleUrls: ['./layout.component.scss'],
})
export class LayoutComponent {
@HostListener('$.class.collapsed')
readonly collapsed = asCallable(this.ui.sideNav);
constructor(
{nativeElement}: ElementRef,
private ui: UiService,
) {
nativeElement['$.class.collapsed'] = this.ui.sideNav;
}
} Also note |
Beta Was this translation helpful? Give feedback.
Unfortunately for now it's not possible without hacks. You can remove
@HostBinding
and change your code to this:Also note
asCallable
utility function, it is there just to trick@HostListener
into believing it's a callback.