Hi
I have below code and i want to convert it using @for condition. education is an array
{{val}}
Thanks
Hi
I have below code and i want to convert it using @for condition. education is an array
{{val}}
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question.
Ramco RamcoPosted Jun 4, 2024, 5:12 AM
Hi Jobin
It is giving error - @for loop lust have a track expression.
Thanks
Jobin SPosted Jun 3, 2024, 1:53 PM
Hi Ramco,
check this and your code alse
ts File:
educations:any= [ {id: 1, name: 'B.E'}, {id: 2, name: 'B.Tech'}, {id:3, name: 'M.Sc'}, ];
Ramco RamcoPosted Jun 3, 2024, 6:08 AM
Hi All
Like below can't we use it in select statement
@for (item of employeeArray;track $index){
Thanks
Mrunali SawantPosted Jun 3, 2024, 5:40 AM
In Angular, you don't use the
@fordirective (which is specific to Razor syntax in ASP.NET). Instead, Angular uses the*ngFordirective to iterate over arrays in templates. Since you're already using*ngFor, it looks like there is a minor typo in your code (educaionshould beeducation). Here's the corrected code:If
educationis an array in your component, this will iterate over it and create afor each element.Ramco RamcoPosted Jun 3, 2024, 5:34 AM
Hi Vishal
Can't it be done with @for instead of ngfor
Thanks
Ramco RamcoPosted Jun 3, 2024, 5:32 AM
Hi
I am getting error 'Cannot parse expression' on line (let val of education)
@for(let val of education){
}
Thanks
Vishal JoshiPosted Jun 3, 2024, 5:29 AM
Hello Ramco,
Please try the below sample code to use @for Loop in your code.
Thanks
Vishal Joshi
Jobin SPosted Jun 3, 2024, 5:20 AM
Hi Ramco,
@for(let val of education){
}
Try this
Rajeesh MenothPosted Jun 3, 2024, 5:11 AM
Try this code: