Link to home
Start Free TrialLog in
Avatar of ocean O
ocean OFlag for United States of America

asked on

How can I add new rows after click a button in angular

Hi,
I have a question about adding a new <div>row in Angular 8. Below is the code in html, which had one row ,includes 3 items (Activity Level/value/Description). When user click the button "Add Additional Activity Level", it needs to insert  a new row of them 3 items.
How can I do it? Do I need to create a separate component ,which includes those 3 items, then repeat the component?
Any inputs are welcome.

Open in new window



<div id="addActivityLevel" >
          <div>
            <label> Activity Level:</label>
            <tux-select
              id="789"
              data-test=""
              [tooltip]=""
              [placeholder]=""
              placement="right"
              [options]="defineValueTargetDropDown">
            </tux-select>
          </div>
          <div>
            <label>Value:</label>
            <tux-text-input
              id="1211"
              [value]=""
              [readonly]="false">
            </tux-text-input>
          </div>
          <div>
            <label> Description:</label>
            <tux-text-input
              id="127"
              [value]=""
              [readonly]="false">
            </tux-text-input>
          </div>
        </div>
        <div>
          <tux-button
                      name="btnAdd"
                      data-test="btn-title"
                      (click)="handleAddActivityLevelClick()"
                      size="sm"
                      type="button"
                      class="">
            <i class="icon add blue mr-sm-1 align-bottom"></i><span>Add Additional  Activity Level</span>
          </tux-button>
        </div>

Open in new window


ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ocean O

ASKER

Thank you!
You are welcome.