Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

ngIf and array values #7708

Closed
Closed
@thorn0

Description

@thorn0

Consider the following code:

  <table ng-if="items" border='10'>
    <tr ng-repeat="item in items track by item.id">
      ...
      <td><a ng-click="removeFromList(item)">Remove</a>
      </td>
    </tr>
  </table>

removeFromList modifies the existing array, so the array is always the same object. After the user deletes all the items, we might expect the table will be removed from the DOM because of ngIf and the fact that empty arrays are considered falsy in ngIf, ngShow, etc. However, it doesn't happen.

A plunk to play with: http://plnkr.co/edit/FVM0k2K3t4HutA4pZDk4?p=preview

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions