javascript - ng-if not catching updated $scope values -
i have been away angular 1.x
long seem have forgotten important ng-if
. have function updates scope value whenever carousel changes images tracking active index of carousel array. have ng-if
set remove 1 element , insert when index reaches end of array, this:
<span ng-if="activeindex < 4" class="back-button" ui-sref="app.profile.index({uid: user.uid})"> skip <i class="ion-chevron-right"></i> </span> <span ng-if="activeindex === 4" class="skip-button" ui-sref="app.profile.index({uid: user.uid})"> continue <i class="ion-chevron-right"></i> </span>
but isn't working. believe ng-if
creates new scope may why isn't catching updated values, if case, easy way update scope of ng-if
? or turned around?
here's codepen
showing problem: http://codepen.io/datatype_void/pen/zqjgor?editors=1001
i added $scope.$apply();
after activeindex change, , solved problem.
function(swiper){ $scope.activeindex = swiper.activeindex; $scope.$apply();
though i'm not sure why isn't applied automatically.
working code: http://codepen.io/c14l/pen/bpkrlo?editors=1111
(also changed max value 2 because never got 4 before, wasn't problem.)
Comments
Post a Comment