How do get Aurelia to render my view after dynamically adding a custom element to the DOM?

后端 未结 1 1201
心在旅途
心在旅途 2021-01-17 16:35

When creating a custom element in the DOM and adding a respective view model which implements bindable from the aurelia-framework, my view renders perfectly.

custom

1条回答
  •  北恋
    北恋 (楼主)
    2021-01-17 17:03

    I would modify as follows:

    //chatbox.js
    export class Chatbox {
       answers = [{
          name:'Reah Miyara',
          nickname:'RM'
       }];
       addCustomElement() {
          answers.push({
            name:'Joe Smith',
            nickname: 'JS'
          }];
       }
    }
    

    Then in your template, use a repeat.for on the answers property. Aurelia's binding system will ensure that there is an tag for each element in the answers array.

    
    
    

    0 讨论(0)
提交回复
热议问题