Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PolymerJS: How to output Model data?

Is there a way to output all model data of polymer elements?

I would like to output each property and their value to the view.

I know vue accomplishes this, by using

{{ $data | json }}

But Vue also has a data attribute that is dumpable. Not sure if it is even possible in polymer to dump every property and their value into the view.

I'd like to use something similar with polymer. But how?

I know doing something like this doesn't work:

{{ $properties }}
like image 268
LoveAndHappiness Avatar asked Nov 07 '15 03:11

LoveAndHappiness


1 Answers

As far as I know, there is no filters in data bindings in PolymerJS like vue has.

But you can use so called Computed binding:

<dom-module id="view">

  {{dump(model)}}

  <script>
    Polymer({
      is: 'view',
      properties: {
        model: Object       
      },
      dump: function(model) {
        return JSON.stringify(model, null, ' ');
      }
    });
  </script>

</dom-module>
like image 199
Maxim Lanin Avatar answered Nov 20 '22 21:11

Maxim Lanin