ng-repeat show only last element

前端 未结 3 2004
耶瑟儿~
耶瑟儿~ 2021-02-12 16:51

I am developing inbox for messages with AngularJs, and I came across one issue: I want to show only last element within ng-repeat. I did some research, and found ou

3条回答
  •  心在旅途
    2021-02-12 17:30

    You could use limitTo filter with -1

    Example :

    {{friend.name}}

    See fiddle

    But if you are showing only one element, maybe you want to get rid of the ng-repeat... :

    {{friends[friends.length - 1].name}}

提交回复
热议问题