Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sw-broadcast expression cant use && or ||? #12

Open
einsitang opened this issue Mar 23, 2016 · 2 comments
Open

sw-broadcast expression cant use && or ||? #12

einsitang opened this issue Mar 23, 2016 · 2 comments

Comments

@einsitang
Copy link

I make a function like "load more end" , but when I first enter , that event("load more end") will trigger,this is my code :

let loadMoreEndDefer;
                let loadMoreEndDeger;
               //here is a real function for the app
                $scope.$on('load more end', ($evt, n, locals) =>{
                    // For the "end" button
                    $log.debug('load more...');

                    return;
                    if(!loadMoreEndDefer){

                        loadMoreEndDefer = userListCtrl.loadMoreEnd(20);
                        loadMoreEndDefer['finally'](()=>{
                            loadMoreEndDefer = null;
                        })

                    }

                });
                //here is a test function for debug
                $scope.$on('test',($evt, n, locals)=>{
                    $log.debug($evt,n,locals);
                });

and my view setting like this :

scroll-watch="{from:0,to:-1,stage:'dialog'}"
sw-broadcast="{'load more end':'$progress ==1 && $positive!=-1','test':true}"

when I first enter,I see the console show this log:

load more...   <- here is the 'load more end' event
{$positive: -1, $negative: -1, $progress: 1, $percentage: 100, $direction: 0…}   <= here is the 'test' event

that mean
'load more end':'$progress ==1 && $positive!=-1' cant work ?
I try use and even & replace && , but will show me error stack

@einsitang
Copy link
Author

I try to change 'load more end':false,'test':true,but the load more end still trigger,look like there is no difference with the test

@pc035860
Copy link
Owner

Hi @forfuns ,

I tried to recreate the result you described.

$positive: -1

http://plnkr.co/edit/KXFVv8VUUJOtJ4v2oW4X

This is caused by the page not having any scrollbar I guess.

Working demo of $progress == 1 && $positive != -1

http://plnkr.co/edit/uT9TW1wk0AfbmcZOquHB
(scroll down and filter the console output with @load1)

  • @load1 log of load more
  • @load2 log of load more end

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

No branches or pull requests

2 participants