Comma Separated

angular

前端 未结 7 1118
清歌不尽
清歌不尽 2020-12-31 17:25

I have a pretty basic scenario (somewhat new to angular). I am trying to convert JSON:

[
    {\'name\': \'Nick\'},
    {\'name\': \'David\'},
    {\'name\':         


        
7条回答
  •  青春惊慌失措
    2020-12-31 18:00

    If you are open to use instead of

    , then following array of objects,

    [
          { "name": "John" },
          { "name": "David" },
          { "name": "Gopal" },
          { "name": "Anil" },
          { "name": "Gurjeet" }
    ]
    

    can be displayed as: John, David, Gopal, Anil and Gurjeet

    with this code snippet:

    {{$first ? '' : $last ? ' and ' : ', '}}{{admin.name}}
    

    Got this solution from: AngularJS ng-repeat, comma separated with 'and' before the last item

    Thanks!

提交回复
热议问题