windows 10 pro office 2019 pro office 365 pro windows 10 home windows 10 enterprise office 2019 home and business office 2016 pro windows 10 education visio 2019 microsoft project 2019 microsoft project 2016 visio professional 2016 windows server 2012 windows server 2016 windows server 2019 Betriebssysteme office software windows server https://softhier.com/ instagram takipçi instagram beğeni instagram görüntüleme instagram otomatik beğeni facebook beğeni facebook sayfa beğenisi facebook takipçi twitter takipçi twitter beğeni twitter retweet youtube izlenme youtube abone instagram

correct way of inserting external referenced template in polymer dart?

Asked By: Anonymous

From this answer https://stackoverflow.com/a/26891895/2117440, I know that is possible to bind a referenced template. However when I do this:

<polymer-element name="data-ul" extends="ul" attributes="items">
  <!-- this is the replacement of content tag -->
  <template repeat="{{item in items}}">
    <template bind="{{item}}" ref="itemTemplate"></template>   
    <input type="button" value="Add Item" on-click="{{addItem}}"/>
  </template>
  <a href="http://data-ul.dart">http://data-ul.dart</a>
</polymer-element>

and the respective dart class:

@CustomTag('data-ul')
class DataUl extends LiElement with Polymer, Observable {
  DataUl.created() : super.created();

  @published List items;

  void parseDeclaration(Element elementElement) {
    var t = this.querySelector('#itemTemplate'); // Gets the template with id itemTemplate from the content html
    if(t != null)  // if not null
      elementElement.append(t); // append itemTemplate to elementElement

    super.parseDeclaration(elementElement); // call super
  }

  void addItem(Event e) {
    var item = nodeBind(e.target).templateInstance.model['item'];
    items.add(item);
  }
}

the items get added to the model correctly, but the itemTemplate is not rendered again. I think this is because the itemTemplate is removed from the scope, so it cannot be accessible again for rendering.

Should I use other method instead parseDeclaration?

Should I insert the itemTemplate in other place?


Solution

Answered By: Anonymous

Instead of using elementElement, we should use element.templateContent:

@CustomTag('data-ul')
class DataUl extends LiElement with Polymer, Observable {
  DataUl.created() : super.created();

  @published List items;

  void parseDeclaration(Element elementElement) {
    // We need to remove previous template from element.templateContent
    // in that way it no continues adding a new content every time that we instantiate 
    // this component.
    var previousTemplate = element.templateContent.querySelector('#itemTemplate');
    if(previousTemplate != null)
      previousTemplate.remove();

    var t = this.querySelector('#itemTemplate'); // Gets the template with id itemTemplate from the content html
    if(t != null)  // if not null
      element.templateContent.append(t); // append itemTemplate to element.templateContent
    else
      element.templateContent.append(new TemplateElement()..id='itemTemplate');  //if no template is added append an empty template to avoid errors

    super.parseDeclaration(elementElement); // call super
  }

  void addItem(Event e) {
    var item = nodeBind(e.target).templateInstance.model['item'];
    items.add(item);
  }
}

techinplanet staff


Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno
Alanya escort Manavgat escort Fethiye escort Kemer escort Didim escort http://www.kadinescort.net Gaziantep escort Denizli escort Adana escort Hatay escort Aydın escort İzmir escort Ankara escort Antalya escort Bursa escort İstanbul escort Kocaeli escort Konya escort Muğla escort Malatya escort Kayseri escort Mersin escort Samsun escort Sinop escort Tekirdağ escort Eskişehir escort Yalova escort Rize escort Amasya escort Balıkesir escort Çanakkale escort Bolu escort Erzincan escort Şırnak escort Van escort Yozgat escort Zonguldak escort Afyon escort Adıyaman escort Bilecik escort Aksaray escort Ağri escort Bitlis escort Siirt escort Çorum escort Burdur escort Diyarbakir escort Edirne escort Düzce escort Erzurum escort Kırklareli escort Giresun escort Kilis escort Kars escort Karabük escort Kırıkkale escort Mardin escort Kırşehir escort Maraş escort Manisa escort Muş escort Kastamonu escort Ordu escort Nevşehir escort Sakarya escort Osmaniye escort Şanliurfa escort Sivas escort Trabzon escort Tokat escort Ardahan escort Bartın escort Karaman escort Batman escort Bayburt escort Bingöl escort Elaziğ escort Gümüşhane escort Hakkari escort Isparta escort Uşak escort Igdır escort