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:
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>
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 {}
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', ...
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, ...
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....