fruits = [ 'Apple', 'Orange', 'Pear' ];
<ul>
<li *ngFor="#fruit of fruits, #i = index">{{fruit}} - {{i}}</li>
</ul>
Alın tüm kullanabileceğiniz değişkenler ise:
Local Variables for ngFor
NgFor
provides several exported values that can be aliased to local variables:index
will be set to the current loop iteration for each template context.- Item index'i geliyor
first
will be set to a boolean value indicating whether the item is the first one in the iteration.- Item ilk elemansa true geliyor
last
will be set to a boolean value indicating whether the item is the last one in the iteration.- Item son elemansa true geliyor
even
will be set to a boolean value indicating whether this item has an even index.- Item index'i çift ise true geliyor
odd
will be set to a boolean value indicating whether this item has an odd index.- Item index'i tek ise true geliyor
Günün sözü: "Profesyonel yaklaşım fark yaratır." :P :D
Hiç yorum yok:
Yorum Gönder