What can cause Angular $apply to omit some evaluation very occasionally?

时间:2016-10-20 13:03:19

标签: css angularjs

options.html

<li class="former-options" ng-repeat="o in formerQuestion.options" ng-click="select(formerQuestion, o)">
    {{::o.title}}
</li>
<div class="block-following-boxes" ng-if="!formerOptionSelected()"></div>
<div class="following-boxes">
  <ul ng-repeat="question in following-questions">
    <li class="following-options" ng-repeat="o in question.options" ng-click="select(question, o)">
      {{::o.title}}
    </li>
  </ul>
</div>

options.js

$scope.formerOptionSelected = function() {
    if ($scope.formerQuestion) {
      var selected = $scope.formerQuestion.options.filter(function(o) {return o.selected == true;});
      return selected.length > 0;
    } else {
      return false;
    }
}

$scope.select = function(question, option) {
    question.options.forEach(function(o) {
        o.selected = false;
    });
    option.selected = !option.selected;
}

Hi, thanks for reading my question.

Of course there are bunch of boilerplate code but it's the essence of my code.

There's a line of radio boxes and i want following another boxes to be disabled while former choice is not selected.

I didn't want to change style of every boxes following former one so made a "blocking transparent div" using ng-if and it worked well at least for over 500 trial till now.

and today "blocking div" didn't disappear after clicking on former box. former boxes still worked so i could change my choice but "blocking div" still stayed there and following boxes were unclickable.

I couldn't debug right then and i'm having hard time trying debugging and making reoccurence of same bug.

Can anyone tell me any hint of this problem?

0 个答案:

没有答案