0

I have an array called altSegments, and based on $scope.firstSeg or $scope.lastSeg I'd like to display different parts of that same array. In most cases I change the altSegments array alltogether and it updates fine, but when I go from the same altSegments array to the same array but change the $scope.firstSeg and $scope.lastSeg it doesn't update properly.

I suspect it has something to do with altSegments not having changed and therefore AngularJS deciding that it's not worth it to go over the code again and re-display. How would I get around this?

<li ng-repeat="altseg in altSegments">
  <!-- For multiflight home to first -->
  <div ng-show="{{firstSeg}}" ng-repeat="flights in altseg.segment_details_1.leg_details">
    <p class="small dark">
      <strong>Flight:</strong> {{flights.Carrier}} {{ flights.FlightNumber}}
    </p>
    <p class="small dark">
      <strong>Departure:</strong> {{flights.OriginName}} | {{flights.DepartureTime | splitDT }}
    </p>
    <p class="small dark">
      <strong>Arrival:</strong> {{flights.DestinationName}} | {{flights.ArrivalTime | splitDT }}
    </p>
  </div>
  <!-- For multiflight last to home -->
  <div ng-show="{{lastSeg}}" ng-repeat="flights in altseg.segment_details_2.leg_details">
    <p class="small dark">
      <strong>Flight:</strong> {{flights.Carrier}} {{ flights.FlightNumber}}
    </p>
    <p class="small dark">
      <strong>Departure:</strong> {{flights.OriginName}} | {{flights.DepartureTime | splitDT }}
    </p>
    <p class="small dark">
      <strong>Arrival:</strong> {{flights.DestinationName}} | {{flights.ArrivalTime | splitDT }}
    </p>
  </div>

1
  • 2
    You don't have to use interpolation operator {{}} on ng-show Commented Jun 12, 2017 at 12:40

2 Answers 2

1

ng-show is an angular directive and evaluates angular code;

Therefore; you do not need : ng-show="{{firstSeg}}"

Remplace with : ng-show="firstSeg"

See full documentation of ng-show here: https://docs.angularjs.org/api/ng/directive/ngShow

Sign up to request clarification or add additional context in comments.

Comments

0

it looks like you are using ng-show="{{firstSeg}}" this should be ng-show="firstSeg" ..

If still doesn't work, Try to update the data from controller side in $scope.apply() ...

e.g :-

$scope.apply(function(){
  list = updated_list;    // put your updation of list here 
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.