Hello, @jaimebs and @alvarolb
I’m trying to put values from a nested JSON in the HTML Widget, but apparently the AngularJS directives aren’t working properly.
I tested the example in the documentation and it didn’t work.
So, I was wondering if it was a bug, or if I’m not writing the code correctly.
-
Problem: Are AngularJS directives working correctly? The example in the documentation does not work. Had to change “entry” to “value”. Only with this change did it work.
Documentation example:
But it only worked when I changed “entry” to “value”. (Bucket Data):
-
How to access values in a nested JSON obtained from Device Properties? Am I doing it wrong, or is it a bug?
It seems that you are using a HTML Widget instead of an HTML Time Series Widget, is it?
Hello @alvarolb
I’m using HTML Widget.
blue arrow in the image
Am I doing something wrong?
Yes, please, use the HTML Time Series Widget
I never developed with “Html Time Series”.
Did I do it right? If yes, nothing appeared in the table.
Note that instead of ‘distance’ it is identified as ‘Default’
It only worked after changing the name ‘distance’ to ‘Default’ in the code. Is this behavior correct?
You should use the name you specify in the time series in the name
field.
Using distance
alone as you expected will not work if you add another bucket that contains data with the same field name So, for each time series you add, you set it a name, i.e., distance, distance_1, distance_2, or whatever that fits your use case, and then you can reference it using the custom name.
Oh, OK. Sorry. It’s the first time I use HTML Time Series.
But in relation to using the Device properties fields (as in the JSON of the image: ‘teste_number_2’, ‘teste_string_2’…) in the HTML Widget? How would it be? I would like to show information in it:
Ex:
Teste_number::
Teste_string:
The Device Property JSON:
Hello, @alvarolb
It’s something related to JSON nesting.
You can get first-level fields from JSON, but not second-level ones.
Is something wrong with my code or some AngularJS Directives setting?
At first, this was my question from the beginning: How to get nested levels data from JSON (Device Property) to use in HTML Widget.
Sorry for the confusion at the beginning of the topic.
I was successful using the {{value['nivel_2.test_number_2']}}
notation:
// sucess
<p>valor B: {{value['nivel_2.teste_number_2']}}</p>
// error
<p>valor B: {{value.nivel_2.teste_number_2}}</p>