Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4838

How to add a child component to the main component through javascript in Ember Octane

$
0
0

@Murali wrote:

Hi,

I have main component with a button. Whenever this button is clicked I want to instantiate and add a child component to a “div” in the main component . It’s like adding rows on button click. How do I implement this behavior.

Here is the pseudo code.

MainCompoent.hbs

<div id="placeHolder>   </div>
<button onClick={{this.clickAdd}}> Add </button>


MainCompoent.js
 @action
 clickAdd() {
   //How to initialize Row Component and add to the placeHolder
   // For example document.getElementById("placeHolder").innerHTML += `<RowComponent/>`;
}

RowComponent.hbs
  <div>    
    <input name>  
    <input age>   
 </div>

r1

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4838