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

Angular2 version of pulltorefresh #11

Closed
yeulucay opened this issue Jul 7, 2016 · 3 comments
Closed

Angular2 version of pulltorefresh #11

yeulucay opened this issue Jul 7, 2016 · 3 comments

Comments

@yeulucay
Copy link

yeulucay commented Jul 7, 2016

I want to add your component to my {N} Angular app.

and added this in my component ts file.

import { registerElement, ViewClass } from "nativescript-angular/element-registry";

registerElement("PullToRefresh", () => {
    var viewClass = require("nativescript-pulltorefresh").PullToRefresh;
    return viewClass;
});

in the view page used it like that

   <pullToRefresh>
        <ListView [items]="groceryList" row="2" class="small-spacing" [class.visible]="listLoaded">
            <template let-item="item">
                <Label [text]="item.name" class="medium-spacing"></Label>
            </template>
        </ListView>
    </pullToRefresh>

It works and refresh spinner is shown on the top of the list when you pull down. But it should somehow trigger a method. lets suppose method name is

refreshList(){}

how will I use it from the view?

@bradmartin
Copy link
Collaborator

There is a refresh event on the component. I'm not sure about ng2 as I
don't use it yet but it does work as I've seen people using it on the slack
channel. So I'm guessing just add the refresh event, look at the sample on
the README

On Thu, Jul 7, 2016, 8:23 AM Yunus Emre Uluçay notifications@github.com
wrote:

I want to add your component to my {N} Angular app.

and added this in my component ts file.

import { registerElement, ViewClass } from "nativescript-angular/element-registry";

registerElement("PullToRefresh", () => {
var viewClass = require("nativescript-pulltorefresh").PullToRefresh;
return viewClass;
});

in the view page used it like that

It works and refresh spinner is shown on the top of the list when you pull
down. But it should somehow trigger a method. lets suppose method name is

refreshList(){}

how will I use it from the view?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#11, or mute
the thread
https://github.com/notifications/unsubscribe/AFulhDVGXHezDaKYirg4YazFpK3uxyX_ks5qTP3pgaJpZM4JHEp_
.

@leocaseiro
Copy link
Contributor

leocaseiro commented Jul 18, 2016

You just need to call the refresh event:

<PullToRefresh (refresh)="refreshList($event)">
    <ListView [items]="groceryList" row="2" class="small-spacing" [class.visible]="listLoaded">
        <template let-item="item">
            <Label [text]="item.name" class="medium-spacing"></Label>
        </template>
    </ListView>
</PullToRefresh>
class YourComponent {
    refreshList(args) {
        console.log('do refresh');
    }
}

@bradmartin
Copy link
Collaborator

Closing @yeulucay - if you need help using this see above comment.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants