8
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

NgForOfとNgFor、、、、ngFor let-~~~ [ngForOf]=""という書き方

Posted at

Angularプロな同僚が書いたソースに見慣れないngFor let-~~~ [ngForOf]=""というコードがあり、参考書に記載無かったので本人に聞いてみました。

1.jpg

Angularのループ処理は、 NgFor がDEPRECATED(非推奨)になり、NgForOfが推奨になった

馴染みのあるNgFor、つまりlet a of bは非推奨になっており、代わりにNgForOf、コードだとngFor let-a [ngForOf]="b"が推奨されているようです。

例えばJavaScriptをNgForOfに変えるとこうなります

JavaScript

let i = 0;
for (let detail of details) {
	i++
}

NgForOf

ngFor let-detail [ngForOf]="details" let-i="index"

https://angular.io/api/common/NgFor
たしかにDEPRECATED(非推奨)と書かれていて、NgForOfのURLが埋め込まれています。

ご参考までに。

8
4
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?