0

how to get array last index + 1 using ng-repeat directive ?? dynamic Profile.addresses[2].site_name

<tr ng-repeat="lines in array">
  <td>
    <input type="text" class="form-control" id="inputDefault" ng-model=' Profile.addresses[2].site_name ' name='site_name'>
  </td>
  <td>
    <input type="text" class="form-control" id="inputDefault" ng-model=' Profile.addresses[2].street_address ' name='street_address'>
  </td>
  <td>
    <input type="text" class="form-control" id="inputDefault" ng-model=' Profile.addresses[2].city ' name='city'>
  </td>
  <td>
    <input type="text" class="form-control" id="inputDefault" ng-model=' Profile.addresses[2].state ' name='state'>
  </td>
  <td>
    <input type="text" class="form-control" id="inputDefault" ng-model=' Profile.addresses[2].country ' name='country'>
  </td>
  <td>
    <input type="text" class="form-control" id="inputDefault" ng-model=' Profile.addresses[2].zip_code ' name='zip_code'>
  </td>
  <td>
    <input type="text" class="form-control" id="inputDefault" ng-model=' Profile.addresses[2].phone_number ' name='phone_number'>
  </td>

</tr>
0

1 Answer 1

6

You'll be looking for $last.

In the ngRepeat documentation there are a number of special properties such as $index, $first, and $last is one of them.

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

5 Comments

Profile.addresses {{$last}}.site_name ?? like this ?
@AdeelKhan - Like this Profile.addresses[$last].site_name
how to get last index +1 value ? ng-model=' Profile.addresses [$last + 1].site_name like this not working
@tymeJV i want lastindex + 1 number, like last index 2 i want 3
Are you trolling us? The last index + 1 does not exist and is outside of the array bounds! If you are saying you just want the number of the last index + 1, you can add 1 to it yourself.

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.