简体   繁体   English

我应该在 Angular 9 中使用什么来代替 @HostBinding(“@grow”)?

[英]What should I use instead of @HostBinding(“@grow”) in Angular 9?

I have this directive that I use to animate changes in height of components.我有这个指令,我用它来动画组件高度的变化。 But since we updated from Angular 8 to 9 it almost looks like the hostPropertyName @grow is no longer supported.但自从我们从 Angular 8 更新到 9 后,几乎不再支持 hostPropertyName @grow This is the directive:这是指令:

import {
  Directive,
  OnChanges,
  Input,
  ElementRef,
  HostBinding
} from "@angular/core";

@Directive({
  selector: "[smoothHeight]",
  host: { "[style.display]": '"block"' }
})
export class SmoothHeightDirective implements OnChanges {
  @Input()
  smoothHeight;
  pulse: boolean;
  startHeight: number;

  constructor(private element: ElementRef) {}

  @HostBinding("@grow")
  get grow() {
    return { value: this.pulse, params: { startHeight: this.startHeight } };
  }

  setStartHeight() {
    this.startHeight = this.element.nativeElement.clientHeight;
  }

  ngOnChanges() {
    this.setStartHeight();
    this.pulse = !this.pulse;
  }
}

Chrome throws the following error: Chrome 会抛出以下错误:

core.js:6185 ERROR TypeError: Cannot read property '11' of null

Safari comes up with this: Safari 提出了这个:

TypeError: null is not an object (evaluating 'componentLView[RENDERER]')

And Firefox:和 Firefox:

ERROR TypeError: "componentLView is null"

Any suggestions on what I am doing wrong, and how to fix it?关于我做错了什么以及如何解决它的任何建议?

It looks like the problem was with Angular (9.1.2) after updating Angular it seems to work.在更新 Angular 之后,问题似乎出在 Angular (9.1.2) 上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Angular 8 - 如何在衍生产品中使用 @HostBinding 而不是主机 - Angular 8 - How to use @HostBinding instead of host in a derivative 如何在 Angular 中使用 @Hostbinding 来设置动态组件的样式? - How do I use @Hostbinding in Angular to style a dynamic component? Angular 6 @HostBinding('class')和@HostBinding('attr.class')有什么区别 - Angular 6 what is the difference between @HostBinding('class') and @HostBinding('attr.class') 如何在 Angular 2 中将 @HostBinding 与 @Input 属性一起使用? - How to use @HostBinding with @Input properties in Angular 2? Angular 中的 @Input 和 @HostBinding 装饰器有什么区别? - What are the differences between the @Input and @HostBinding decorators in Angular? Angular:这里的@HostBinding 是什么意思? - Angular : what does this @HostBinding mean here? 我应该使用防护装置而不是旋转变压器来保存角度2中的渲染周期吗? - Should I use guards instead of resolvers to save rendering cycles in angular 2? rxjs Subject.create已过时-应该改用什么? - rxjs Subject.create deprecated - what should I use instead? 我应该在 Jasmine 3 中使用什么来代替 fit 和 fdescribe? - What should I use instead of fit and fdescribe in Jasmine 3? 在 Observable 上使用 await 时,我应该使用什么来代替 toPromise()? - What should I use instead of toPromise() when using await on an Observable?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM