Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用于跳过第一个索引的Angular2_Angular_Angular2 Directives - Fatal编程技术网

用于跳过第一个索引的Angular2

用于跳过第一个索引的Angular2,angular,angular2-directives,Angular,Angular2 Directives,如何从数组中跳过第一个索引 <li *ngFor="#user of users"> {{ user.name }} is {{ user.age }} years old. </li> {{user.name}}是{{user.age}岁。 对于此用例,有以下选项: <li *ngFor="let user of users | slice:1"> {{ user.name }} is {{ user.age }} years

如何从数组中跳过第一个索引

<li *ngFor="#user of users">
    {{ user.name }} is {{ user.age }} years old.
  </li>

{{user.name}}是{{user.age}岁。

对于此用例,有以下选项:

  <li *ngFor="let user of users | slice:1">
    {{ user.name }} is {{ user.age }} years old.
  </li>

{{user.name}}是{{user.age}岁。

您可以使用


{{user.name}}是{{user.age}岁。


第一个参数对应一个表示起始索引的正整数。

是否有办法保持索引值不变?而不是移动到0。对于切片管道,索引保持不变。在迭代过程中,只有第一个元素没有被考虑进去……实际上,当我使用slice时,索引值变为0。我将这样实现:Cool;-)事实上,在初始化索引时不能计算表达式(类似于
#i=index+1
)……有没有办法保持索引值不变?而不是移动到0。什么索引值?如果这是您的意思,您可以尝试
。使用切片后,第一个用户的索引值从1变为0。所以我需要保持索引值不变。。从1开始
<li *ngFor="#user of users | slice:1">
  {{ user.name }} is {{ user.age }} years old.
</li>