【问题标题】:Problem with NgStyle after upgrading angular from 5.1 to 8将角度从 5.1 升级到 8 后 NgStyle 出现问题
【发布时间】:2019-07-09 15:26:51
【问题描述】:

Angular form 5.1 升级到 8 后,从 '@angular/common' 导入的模块 NgStyle 报错, 在 5.1 NgStyle 中使用接受 3 个参数,而在 8 中它只接受一个参数。

import { NgStyle } from "@angular/common";

@Directive({
	selector: '[chartContainer]'
})
export class ChartContainerDirective implements OnInit {
this.ngStyle = new NgStyle(this._differs, divRef, this.renderer);
}

请为此提出一条出路。

【问题讨论】:

    标签: javascript node.js angular typescript ecmascript-6


    【解决方案1】:

    Angular 版本 8 更改了 NgStyle 的 API,因此它现在只接受 1 个参数

    这是 NgStyle 的构造函数

    new NgStyle(delegate: ɵNgStyleImpl): NgStyle
    

    所以你需要传入一个委托

    【讨论】:

    • 你能解释一下什么是 eNgstyleImpl 类型的委托,对此没有太多了解,如果想创建 NgStyle 的新实例,应该为委托分配什么
    猜你喜欢
    • 1970-01-01
    • 2019-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-20
    • 2020-03-07
    • 2021-08-22
    相关资源
    最近更新 更多