Widget: Listing items with corresponding label, icon and state by using ng-repeat="item

Hi.
I have tried for hours, and search documentation, examples and tutorials, but I can not figure out how to list the icons.
I am using the following code in a widget:

<h4><strong>DAYLIGHT, SUN AND MOON</strong></h4>
<table class="table table-condensed">
	<tr ng-repeat="item in itemsInGroup('daylight')">
    <td> I WANT CORRESPONDING ICONS HERE!!!</td>
    <td class="text-right">{{item.label}}</td>
    <td class="text-left">{{itemState(item.name)}}</td>
  </tr>
 </table> 

This results in a nice table with labels and itemState, but no icons.

Code from one of my widgets. Who’s Home. See in the gallery.

      <tr ng-if="(config.whoshome_show_icon && item.category != '' && config.whoshome_iconset != '')">
            <td class="table_icon"><widget-icon iconset="config.whoshome_iconset" icon="item.category.toLowerCase()" size="config.whoshome_iconsize" backdrop="false" center="true" inline="false" state="itemState(itemname)"></td>
          </tr>
1 Like

Thank you, I can not believe I did not see that, since I looked on the code for also that widget.
The resulting code is then:

<h4><strong>DAYLIGHT, SUN AND MOON</strong></h4>
<table class="table table-condensed">
	<tr ng-repeat="item in itemsInGroup('dylight')">
    <td><widget-icon iconset="'eclipse-smarthome-classic'" icon="item.category.toLowerCase()" size="50" backdrop="false" center="true" inline="false" state="itemState(itemname)"></td>
    <td class="text-right">{{item.label}}</td>    
    <td class="text-left">{{itemState(item.name)}}</td>
  </tr>
</table>

Just, a last curious question. If there is no documentation on this (which I could not, and can not find), where should I look (in source code, or other places) to find clues of what to test? I mean, I could expect to use ‘toLowerCase()’, but where to find what is returned when using ‘item.category’ and similar?

NP. Glad it helped.

Plagiarism is a big part of writing code :stuck_out_tongue:

I scratch around other peoples widgets for ideas and clues and, seeing as this is all Angular, any angular help normally also works in the widgets. And of course, people here help :slight_smile:

1 Like