I have a Json array that I want to use in my template file, but to access certain elements of the array I need to use a scope variable. I can do something like this in the controller, but I need to do it in the html file.
Part of my array is shown below:
{
fitbit: {
selected: true,
user_id: "10537",
today: [
{
date: "Tue, 10 Jan 2017",
distance: 0,
steps: 0,
calories: "0"
}
],
week: {
distance: [
["0","0","0","0","0"]
],
labels: ["Wed 4th","Thu 5th","Fri 6th","Sat 7th","Sun 8th"],
steps: [
["0","0","0","0","0"]
]
}
},
jawbone: { ... }
}
I have a scope variable $scope.currentDevice
that will change depending on what option the user picks so fitbit, jawbone, etc.
In the controller I can control which data to access using
$scope.wearables[currentDevice]['week']['distance']
so that it gets the correct data using the variable currentDevice.
I need to access wearables[currentDevice]['week']['distance']
in the template html file but without using ng-repeat and I need to use the scope variable currentDevice to to decide which data to show.
Whenever I try {{wearables[currentDevice]['week']['distance']}}
in the html file it shows nothing but if I try {{wearables['fitbit']['week']['distance']}}
it show the value.
Is it possible to show the array data this way and if so how would i do it?
The array data I want to show needs to be displayed in a graph like below where chart-data changes
<canvas id="bar" class="chart chart-bar" chart-data="wearables[currentDevice]['week']['distance']" chart-labels="labels" chart-series="series" chart-options="options" ></canvas>
if i change it to
<canvas id="bar" class="chart chart-bar" chart-data="wearables['fitbit']['week']['distance']" chart-labels="labels" chart-series="series" chart-options="options" ></canvas>
it works fine
currentDevice
gets changed?