Babban matsalar da ke da alaฦa da yin amfani da umarnin ngFor tare da fihirisa shine cewa zai iya haifar da sakamako mara tsammani lokacin da aka ฦirฦiri bayanan akan canje-canje. Wannan saboda ba a sabunta fihirisar ta atomatik lokacin da aka ฦara ko cire abubuwa daga tsararrun, don haka idan an ฦara sabon abu a maฦasudin 0, duk sauran abubuwan za a canza maฦasudinsu ษaya. Wannan na iya haifar da bayyanar da bayanan da ba daidai ba a ra'ayin ku ko halin da ba zato ba tsammani a cikin aikace-aikacenku.
<ul> <li *ngFor="let item of items; let i = index">{{i}} - {{item}}</li> </ul>
1. Wannan layin code yana haifar da jerin marasa tsari.
2. Ana amfani da umarnin *ngFor don yin madauki ta hanyar tsararrun abubuwa da nuna kowane abu a cikin jerin.
3. Ana amfani da kalmar bari don bayyana mabambantan da ake kira "item" wanda ke riฦe abu na yanzu a cikin maimaita madauki.
4. Hakanan ana amfani da kalmar bari don bayyana ma'anar canji mai suna "i" wanda ke riฦe da index na abin da ke yanzu a cikin maimaita madauki.
5. Wannan layin yana nuna kowane abu a cikin lissafin tare da lambar fihirisa (farawa daga 0).
Menene Angular
Angular tsarin tsarin aikace-aikacen gidan yanar gizo ne na tushen tushen JavaScript na farko wanda Google ke kula da shi da kuma jama'a na mutane da kamfanoni don magance yawancin ฦalubalen da aka fuskanta wajen haษaka aikace-aikacen shafi guda ษaya. Abubuwan JavaScript sun dace da Apache Cordova, tsarin da ake amfani da shi don haษaka ฦa'idodin wayar hannu. Yana nufin sauฦaฦe duka haษakawa da gwajin irin waษannan aikace-aikacen ta hanyar samar da tsari don ฦirar abokin ciniki-gani-duba-mai sarrafa (MVC) da ฦirar-view-viewmodel (MVVM), tare da abubuwan da aka saba amfani da su a cikin aikace-aikacen Intanet masu wadata.
ngFor element
NgFor umarni ne na tsarin Angular wanda ke ba mu damar yin madauki ta hanyar bayanai da ฦirฦirar samfuri ga kowane abu a cikin tsari ko abu. Ana amfani da shi don maimaita abin da aka ba HTML ฦayyadadden adadin lokuta. Ana iya amfani da NgFor don nuna bayanai daga tsararru, abu, ko kirtani. Hakanan za'a iya amfani dashi don ฦirฦirar abubuwan HTML dangane da ฦimar tsararraki ko abu. Ana amfani da NgFor yawanci tare da wasu umarnin Angular kamar ngIf da ngSwitch.
Yadda ake samun fihirisar ngFor element
Kuna iya amfani da madaidaicin maษalli don samun fihirisar wani abu a cikin madauki na ngFor. Ma'anar wannan shine kamar haka:
A cikin wannan misali, madaidaicin "i" zai ฦunshi fihirisar madauki na yanzu. Hakanan zaka iya amfani da wannan canjin don samun dama ko gyara abubuwa a cikin lissafin ku.