Dart enum - Polymer -


i happy new feature in dart.

but, use in web component (polymer)

like this:

file.dart

enum categoria {id, descricao, natureza, id_subcategoria_da, descricao_subcategoria_da, ativo}  @published map itemlist; 

file.html

..

<template>   <paper-input value="{{itemlist[categoria.id]}}"></paper-input> </template>  <script type="application/dart" src="file.dart"> </script>   

..

in value on @published there map itemlist , use enum categoria.id key find value of map.

it´s possible in web component (polymer)?

this isn't supported because types can't used in polymer bindings.

the following expressions aren't supported neither , and enums syntactic sugar similar code:

class someclass {   static final someval = 1; } 
<template if="{{x someclass}}"></template> <template if="{{x == someclass.someval}}"></template> 

as workaround can add method

categoria categoriaenum(string val) =>   categoria.values.firstwhere((i) =>        '${i}'.tostring().tolowercase().endswith('.${val.tolowercase()}')); 

with expression like

<paper-input value="{{itemlist[categoriaenum('id')]}}"></paper-input> 

you move method mixin , make each of polymer elements support enums way applying mixing. still not beautiful though.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -