【问题标题】:ListView not rendering after a SegmentedBar routeListView 在 SegmentedBar 路由后未呈现
【发布时间】:2016-11-19 14:51:27
【问题描述】:

我已经开始使用带有 Angular2 的 Nativescript - 顺便说一句,它很棒。 我在存储库的示例文件夹 (nativescript-angular/ng-sample/app/examples/list/) 中使用了 nativescript-angular2 列表示例。我可以让组件在我的主屏幕上呈现数据。但是,当将 List 组件添加到使用 Router (v3) 路由到的组件中时,数据不会呈现。它只是呈现一个空项目列表。

有人遇到过同样的问题吗?

非常感谢

【问题讨论】:

    标签: nativescript angular2-nativescript


    【解决方案1】:

    是的,我也有同样的问题。开发人员已经知道这个问题,希望我们能尽快修复。

    似乎ngzone在路由后无法启动(导致未观察到任何更改) 作为一种解决方法,请尝试导入:

    import {ChangeDetectorRef,ApplicationRef} from '@angular/core';
    

    ...

    初始化并使用:

    constructor(private _applicationRef: ApplicationRef,private ref:ChangeDetectorRef){
    
            setTimeout(() => {
                _applicationRef.zone.run(() => _applicationRef.tick())
            }, 100)//request with timeout to start zone
    
            this.ref.reattach();//reattach the change detector
                                //(i use it whenever there is a change that will change the template)
    
    }
    

    【讨论】:

      猜你喜欢
      • 2020-03-31
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 2017-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多