How to use ng-repeat to get the value by key

for (var key in filters) { for (var i in filters[key]) { //как ангуляром получить вот это -> filters[key][i] } } 

markup

 <div class="filter" id="{{h.name}}" title="Фильтр по {{h.title}}"> <div ng-repeat="f in filters"></div> </div> 

Filters

 $scope.filters={ "filters": { "Поле1":[ "abc","edf","abw" ], "Поле2":[ "dfe33","jj3","chdy3" ] } } 
  • show the markup on which you want to apply it, and an example filters - Grundy
  • <div class = "filter" id = "{{h.name}}" title = "Filter by {{h.title}}"> <div ng-repeat = "f in filters"> </ div> </ div> - A50
  • add code and markup to the question - Grundy
  • What is the expected result final markup, for reduced filters - Grundy

2 answers 2

ng-repeat is a direct analogue of the loop, if you write in code

 for (var key in filters) { for (var i in filters[key]) { //как ангуляром получить вот это -> filters[key][i] } } 

then in the markup it will be similar

 <div ng-repeat="val in filters"> <div ng-repeat="values in val"> {{values}} - это аналог filters[key][i]. </div> </div> 

In addition, if there is an iteration not only by arrays, but also by objects and besides the field value, you must also output the field name itself, use the following construction

 (key, value) in expression 

    In the div with ng-repeat , {{f}} should be added. In addition, $scope.filters contains only one value - "filters" . Apparently, you should write f in filters.filters and everything will work.

    • Yes, but how can I write the ng-repeat nested, which will go through the array of the object `` Pole1 ": [" abc "," edf "," abw "],` - A50