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

Scope variables not updated in controller but in view #65

Closed gerbsen closed 9 years ago

gerbsen commented 9 years ago

Hey, I like this plugin very much but I have this wired problem where my scope variables are updated in the view part but not in the controller. I have this html from angular-bootstrap

<div class="form-group">
    <label for="traveltime">Travel time: {{ travelTime / 60 }}min</label><br>
    <div class="btn-group">
        <label class="btn btn-r360-1"  ng-model="travelTime"  btn-radio="'300'">5 min</label>
        <label class="btn btn-r360-2"  ng-model="travelTime"  btn-radio="'600'">10 min</label>
        <label class="btn btn-r360-3"   ng-model="travelTime"  btn-radio="'900'">15 min</label>
        <label class="btn btn-r360-4"  ng-model="travelTime"  btn-radio="'1200'">20 min</label>
        <label class="btn btn-r360-5"  ng-model="travelTime"  btn-radio="'1500'">25 min</label>
        <label class="btn btn-r360-6"  ng-model="travelTime"  btn-radio="'1800'">30 min</label>
    </div>
</div>

Travel time is displayed correctly but the variable inside the controller is never updated. Also $scope.$watch('travelTime', function(old, newV){ }) does never fire. If I use this outside of the pageslide everything goes as planned. I've found the workaround with the ng-click="setTravelTime(300)" attribute, but this seems to me a bit hacky. :)

Thank you for this plugin and any help is kindly appreciated, Daniel

danielepiccone commented 9 years ago

I think you are instantiating two controllers somewhere and the scope is not the same, check this plunkr http://plnkr.co/edit/EbSK9M?p=preview travelTime is shared beetween the pageslide and the body

gerbsen commented 9 years ago

hmm. i'm using ngRoute with only one controller that fills ng-view in my index page.. so no 2nd conrollter :(

gerbsen commented 9 years ago

Okay, I found out that this only happens if I load the ui.bootstrap module!?