danielepiccone / ng-pageslide

AngularJS sliding panel for serving additional content from off the page
http://danielepiccone.github.io/ng-pageslide/examples/
451 stars 160 forks source link

dynamic ps-side #168

Closed wawan-diputra closed 6 years ago

wawan-diputra commented 7 years ago

how can we set the ps-side dynamically? I have been trying to set the ps-side attribute from controller but seems not working. anyone know how to resolve this?

YoannB commented 7 years ago

Hi,

It's possible with ps-size so it's just because, there is no watcher on ps-side like this (for ps-size) :

                    scope.$watch('psSize', function(newValue, oldValue) {
                        if (oldValue !== newValue) {
                            param.size = newValue;
                            initSlider();
                        }
                    });
wawan-diputra commented 7 years ago

Hi @YoannB thanks for your respond. I've set the scope.$watch for psSide exactly the same as psSize in angular-pageslide-directive.js but still didn't work. Is there any steps that I missed?

here is what I did. Thank you. angular-pageslide-directive.js :

scope.$watch('psSide', function(newValue, oldValue) {
                        if (oldValue !== newValue) {
                            param.side = newValue;
                            initSlider();
                        }
                    });

Html:

<pageslide ps-push='true' ps-open="slides[1]" ps-side="{{xdirection}}" ps-container='slideContainer' ps-speed="1" ps-click-outside="false">
      <div>
        <div ng-include="'/detailview.html'"></div>
      </div>
    </pageslide>

Controller:

        if (leftbuttonclicked) {
          $scope.xdirection= 'right';
        } else {
          $scope.xdirection= 'left';
        }
YoannB commented 7 years ago

Hi !

See the pull request i made : https://github.com/dpiccone/ng-pageslide/pull/171/commits/52b1267b202d5190491498e12ca2efa930c9f21c

I do fixes into code of directive : https://github.com/YoannB/ng-pageslide/blob/master/src/angular-pageslide-directive.js, can you try ?