【发布时间】:2019-08-04 16:22:59
【问题描述】:
我正在关注 Nativescript Angular Pull to Refresh Styling 演示 (Found here),但无法让 this.myListViewComponent 成为 undefined,因此这个 sn-p 永远不会被触发:
if (this.myListViewComponent && this.myListViewComponent.listView) {
let style = new PullToRefreshStyle();
style.indicatorColor = new Color("red");
style.indicatorBackgroundColor = new Color("blue");
this.myListViewComponent.listView.pullToRefreshStyle = style;
}
这里唯一的区别是它是主页的一部分,正在延迟加载(我不确定这是否重要)。
还有其他方式来设置 PullToRefresh 指示器的样式吗?
以下 sn-p 来自 Nativescript Core 文档,因此不适用于 Angular:
<lv:RadListView.pullToRefreshStyle>
<lv:PullToRefreshStyle
indicatorColor="white"
indicatorBackgroundColor="blue"/>
</lv:RadListView.pullToRefreshStyle>
显然,以下示例不适用于 Angular 代码。还有另一种我想念的方式,就像这个完全假的伪代码:
<RadListView>
<ng-template>...</ng-template>
<PullToRefreshStyle
indicatorColor="white"
indicatorBackgroundColor="blue">
</PullToRefreshStyle>
</RadListView>
我使用的是 Nativescript 6+。
【问题讨论】:
-
您能否分享一个 Playground 示例,以证明您提到的
undefined问题。 -
嗨 Monaj,该链接包含我使用的代码。我完全按原样使用示例。您知道在 HTML 中而不是在 .ts 文件中使用“PullToRefreshStyle”的方法吗?
-
这与 Angular 8 有关系吗?我确实有一个 *if 条件。 {N} 源代码将代码放在
ngOnInt中,但 Angular 文档说将其放在ngAfterViewInit中。当我这样做时,好吧,似乎什么都没有发生。大声笑 -
我建议使用
loaded事件立即获得对组件的访问权限,但如果没有 Playground 示例,我不能说太多。 -
谢谢 Manoj!是否有链接可以看到
loaded事件的示例。
标签: angular nativescript pull-to-refresh