【问题标题】:Dynamically update settings Ng2-smart-table动态更新设置 Ng2-smart-table
【发布时间】:2020-12-17 17:04:03
【问题描述】:

我想在单击按钮后更新“hideSubHeader”值。 'hideSubHeader' 设置中的值已更新,但未反映在我的智能表上。

我的设置,

settings = {
    hideSubHeader: true
}

点击按钮后,

newSettings() {
    const customSettings = settings;
    customSettings.hideSubHeader = false;
    this.settings = Object.assign({}, customSettings);
}

【问题讨论】:

    标签: angular ng2-smart-table ngx-admin


    【解决方案1】:

    你可以使用下一个:

    constructor(private cdr: ChangeDetectorRef) {...}
    
    this.cdr.markForCheck(); // in place where u change some settings
    

    或者如果您在组件设置中设置changeDetection: ChangeDetectionStrategy.OnPush,请将其设为“默认”或使用该设置删除行

    【讨论】:

    • 在 ng2-smart-table 中,表的标题没有得到更新,这是表本身的一些问题,而不是与 UI 相关的东西没有以角度更新
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-08
    • 2019-01-08
    • 2020-01-03
    • 2019-05-29
    相关资源
    最近更新 更多