Delete with ng-if?

Delete with ng-if?

本文关键字:ng-if with Delete      更新时间:2024-01-17

我在一个有角度的html页面上列出故事,如下所示:

<li class="myStories" ng-repeat="story in authors.currentAuthor.stories | orderBy: '-_id'">
       <!--  <span ng-if="checked" class="animate-if"> -->
        Title: {{ story.title }}<br>
        Genre: {{ story.genre }}
  <a ui-sref-active="active" ui-sref="storyEdit({ id: story._id })" 
       id="{{ story._id }}">Edit Story
  </a> 
</li>

Angular文档声明"如果表达式返回false,ng-if指令将删除DOM元素",所以我想知道使用ng-if删除项是否可能/合法?

该项仅从DOM中删除。它仍在您的数据表示中。对于视觉上的东西,它是合法的,而且大多数时候都比ng show好——看:什么时候喜欢ng if而不是ng show/ng hide?