Trying to dynamically add polymer elements on the click event not able to add the element
tried using initPolymer (resulting in stack error :element already initialized)
4 files.
item.html
<polymer-element name="init-item" >
<template>
<input type="image" src="button_minus_red.gif" on-click="{{remove}}">
{{Name}}
</template>
<script type="application/dart" src="item.dart"></script>
</polymer-element>
item.dart:
import 'package:polymer/polymer.dart';
@CustomTag('init-item')
class Item extends PolymerElement{
@observable String Name='hello';
void remove(){
Name='';
}
PlayerItem.created(): super.created(){}
}
index.dart:
import 'package:polymer/polymer.dart';
import 'item.dart'
// getting unused warning for item.dart
main() async{....
//init moved to main
initPolymer().then((_) {});
}
//adding to form element on click event
Code to run(click event)
{ //onReady added here
Polymer.onReady.then((_) { yourPlayer.children.add(new Element.tag('player-item')) ;});
}
tag added to index.html and also dynamic addition as shown above.
Due to above changes when page reloaded was automatically getting custom element included. Removed the element form the index.html works as expected (no Errors)
Previous error: when used initPolymer element added in place of tag and also within form. on subsequent click events added within form but stack error(initialization already done)
Are there any issues due to async(highly false)? How should I approach this?