ng-repeat on two arrays

前端 未结 3 1025
刺人心
刺人心 2021-01-12 00:49

I want to do a ng-repeat on an array which is composed of two arrays, like this :

[titles: [], links: []]

My arrays (titles and links) ha

3条回答
  •  星月不相逢
    2021-01-12 01:46

    It's not clear how you have your data — [titles: [], links: []] isn't meaningful.

    Ideally you would arrange your data as an array of objects that looks like:

    var array = [{title: "foo", link: "bar"}, {title…etc]
    

    Then you could just use:

    {{obj.title}}, {{obj.link}}

    If you know that titles and links will always be the same size you can do this, but it's not very pretty and might be a little fragile:

    {{title}}, {{links[$index]}}

提交回复
热议问题