Skip to content
This repository was archived by the owner on Jun 24, 2021. It is now read-only.
This repository was archived by the owner on Jun 24, 2021. It is now read-only.

Cannot read property 'SwipeRefreshLayout' of undefined #72

@alvmarcoux

Description

@alvmarcoux

I am using Angular Nativescript and the app is giving me the following error when a try to access the template that use this tool:

ERROR Error: Uncaught (in promise): TypeError: Could not load view for: PullToRefresh.TypeError: Cannot read property 'SwipeRefreshLayout' of undefined
 at DebugRenderer2.createElement (file:///data/data/org.nativescript.preview/files/app/tns_modules/@angular/core/bundles/core.umd.js:30492:36)
 at createElement (file:///data/data/org.nativescript.preview/files/app/tns_modules/@angular/core/bundles/core.umd.js:28524:31)
 at createViewNodes (file:///data/data/org.nativ...
 at ViewUtil.createView (file:///data/data/org.nativescript.preview/files/app/tns_modules/@nativescript/angular/view-util.js:214:44)
 TypeError: Could not load view for: PullToRefresh.TypeError: Cannot read property 'SwipeRefreshLayout' of undefined
 at NativeScriptRenderer.createElement (file:///data/data/org.nativescript.preview/files/app/tns_modules/@nativescript/angular/renderer.js:138:30)
 at Object.getViewClass (file:///data/data/org.nativescript.preview/files/app/tns_modules/@nativescript/angular/element-registry.js:84:15)

in main.ts i have:

import { registerElement } from "nativescript-angular/element-registry";
registerElement("PullToRefresh", () => require("nativescript-pulltorefresh").PullToRefresh);

in the template:

<StackLayout class="page__content">
    <Label class="page__content-icon fas" text="&#xf002;"></Label>
    <PullToRefresh (refresh)="onPull($event)"> 
        <ListView class="list-group" [items]="this.noticias.buscar()" (itemTap)="onItemTap($event)"
            style="height:1250px">
            <ng-template let-x="item">
                <FlexboxLayout flexDirection="row" class="list-group-item">
                    <Image src="res://icon" class="thumb img-circle"></Image>
                    <Label [text]="x" class="list-group-item-heading" verticlaAligment="center"
                        style="width: 60%"></Label>
                </FlexboxLayout>
            </ng-template>
        </ListView>
    </PullToRefresh>
</StackLayout>

and in the component

onPull(e) {        
        console.log(e);        
        const pullRefresh = e.object;        
        setTimeout(() => {            
            // this.resultados.push("xxxxxxx");            
            pullRefresh.refreshing = false;        
        }, 2000); 
    } 

I searched on the web and found this post with what is seems to be the same problem:
https://stackoverflow.com/questions/63365237/error-in-nativescript-pulltorefresh-android-cannot-read-property-swiperefres

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions