Access to properties of polymeric expressions by name

tries to display the table as a polymer element

      <table>
          <thead>
            <tr>
               <th template repeat='{{ column in columns}}'>
                  {{column.displayName}}
               </th>
           </tr>
         </thead>
         <tbody>
            <tr template repeat='{{ row in data}}'>
               <td template repeat='{{ column in columns}}'>
                 {{row[column.name]}}
               </td>
            </tr>
         </tbody>
      </table>

      

the following expression doesn't work as i expected

{{row[column.name]}}

      

column.name is the name of the property I want to get on the row object, but it gives the following exception for all properties

NoSuchMethodError: method not found: '[]'
Receiver: Instance of 'Product'
Arguments: ["id"]

      

Is this the correct way to access the property by name?

my line model looks like this

class Product extends Observable{
  int id;
  String name;
  String category;
}

      

One job I don't like is overloading [] in the string class

operator [](String fieldName){
    var im = reflect(this);
    return im.getField(new Symbol(fieldName)).reflectee;
}

      

+3


source to share


1 answer


This should work if "string" is a map.



+2


source







All Articles