skip to Main Content

I want to display items of an array of strings from index 1.

arr = [ "str1", "str2", "str3", "str4", "str5" ]

Output should be:

str2
str3
str4
str5

Print all except first one, using new @for loop in angular.

2

Answers


  1. The slice Pipe is what you are looking for :

    @Component({
      selector: 'app-root',
      standalone: true,
      imports: [SlicePipe],
      template: `
        @for(a of arr|slice:1; track $index) {
          {{a}}
        }
      `,
    })
    export class App {
      arr = [1,2,3,4];
    }
    
    Login or Signup to reply.
  2. Another:

    @for(a of arr;let first=$first;track $index) {
         @if(!first)
         {
           {{a}}
         }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search