JavaScript How can I repeat certain chunks of object with ng-repeat?

I am using AngularJS with MVC file structure. I have a data structure in my controller that I want to display on my view. I have a custom "indicators" directive. Each "title" belongs to an indicator and I am trying to display a group of four indicator elements at a time. I am using nested ng-repeats to display one "chunk" of indicators at a time, but the browser console tells me something is wrong with the syntax of my data structure or doesn't display anything at all. Everything works fine if my indicators object has no "chunks" (nest) and I do one ng-repeat through the object. So I have two questions:

  1. Does anyone know the proper way of doing nested ng-repeats in this context?
  2. Is my indicators object syntax wrong?

Here is my indicators object in my controller:

$scope.indicators = 
[{
    "chunk1": {[
        "ind1": {
            "title": 'AC',
            "active": true
         }, "ind2":{
            "title": 'Aux PS',
            "active": true
         }, "ind3":{
            "title": 'Main PS',
            "active": false
         }, "ind4": {
            "title": 'Shutdown',
            "active": true
         }
    ]},

    "chunk2": {[
        "ind1": {
            "title": 'Tx',
            "active": false
         }, "ind2": {
            "title": 'Rx',
            "active": true
         }
    ]}

}];

Here is the part of my view:

<div ng-repeat="chunks in indicators" >
    <div ng-repeat="ind in chunks">
        <status-indicator title="ind.title" is-green="true" active="ind.active" ></status-indicator>    
    </div>                          
</div>
Answer:1

You json/object structure is incorrect. It should be:

[{
  "chunk1": [{
    "ind1": {
      "title": "AC",
      "active": true
    },
    "ind2": {
      "title": "Aux PS",
      "active": true
    },
    "ind3": {
      "title": "Main PS",
      "active": false
    },
    "ind4": {
      "title": "Shutdown",
      "active": true
    }
  }],
  "chunk2": [{
    "ind1": {
      "title": "Tx",
      "active": false
    },
    "ind2": {
      "title": "Rx",
      "active": true
    }
  }]
}]

Swapped the [] and {}

Answer:2

I want to put my JSON data into Vue data, and a display, why can't I get to work? compiled: function(){ var self = this; console.log('teste'); $.ajax({ url: 'js/fake-ws.json', ...

I want to put my JSON data into Vue data, and a display, why can't I get to work? compiled: function(){ var self = this; console.log('teste'); $.ajax({ url: 'js/fake-ws.json', ...

  1. putting json data into html table
  2. putting json in database
  3. putting data into json object

Let's say I have a simple array like this: var myArr = [0,1,2,3,4,5,6,7,8,9] I'd like to extract a number of elements, starting from a specific index, like this: myArr.getElementsFromIndex(index, ...

Let's say I have a simple array like this: var myArr = [0,1,2,3,4,5,6,7,8,9] I'd like to extract a number of elements, starting from a specific index, like this: myArr.getElementsFromIndex(index, ...

  1. number elements from
  2. number elements in periodic table
  3. number elements in list python
  4. number elements in array python
  5. number elements in array matlab
  6. number elements in array javascript
  7. number elements in list r
  8. number elements in array c++
  9. number elements in numpy array
  10. number elements in array
  11. number elements in array perl
  12. number elements in each period
  13. number elements in a group
  14. number elements of matrix
  15. number of elements matlab
  16. number of elements python
  17. number of elements r
  18. number of elements numpy
  19. elements number of protons
  20. number of elements less than k

I'm very new to JavaScript (and coding) and I'm studying through the book Head First JavaScript. From reading, I thought an anonymous function could be an argument since functions are values, but I ...

I'm very new to JavaScript (and coding) and I'm studying through the book Head First JavaScript. From reading, I thought an anonymous function could be an argument since functions are values, but I ...

I have created a hyperlink from my report and pass through a value successfully. ="http://Applicationlive:8080/ApplicationName/secure/EventReportPage.zul?EventReportId=" & Fields!event_report_id....

I have created a hyperlink from my report and pass through a value successfully. ="http://Applicationlive:8080/ApplicationName/secure/EventReportPage.zul?EventReportId=" & Fields!event_report_id....

  1. open hyperlink from excel
  2. open hyperlink from outlook
  3. open hyperlink from excel in chrome
  4. open hyperlink from vba
  5. open hyperlink from powerpoint
  6. open hyperlink from outlook in chrome
  7. open hyperlink from pdf
  8. open hyperlink from excel vba
  9. open hyperlink from cell vba
  10. open hyperlink from access
  11. open hyperlink from word
  12. open hyperlink from ppt
  13. open hyperlink command
  14. open hyperlink from html
  15. open from hyperlink
  16. open hyperlink in new tab
  17. open hyperlink in new tab html
  18. open hyperlink in chrome
  19. open hyperlink in new window
  20. open hyperlink with specific browser