*ngIf and *ngFor on same element causing error

后端 未结 16 2106
自闭症患者
自闭症患者 2020-11-22 02:37

I\'m having a problem with trying to use Angular\'s *ngFor and *ngIf on the same element.

When trying to loop through the collection in th

16条回答
  •  别那么骄傲
    2020-11-22 02:53

    As @Zyzle mentioned, and @Günter mentioned in a comment (https://github.com/angular/angular/issues/7315), this is not supported.

    With

    • {{log(thing)}} {{thing.name}}

    there are no empty

  • elements when the list is empty. Even the
      element does not exist (as expected).

      When the list is populated, there are no redundant container elements.

      The github discussion (4792) that @Zyzle mentioned in his comment also presents another solution using