Add component to dom on click of button in angular2

前端 未结 1 947
既然无缘
既然无缘 2020-12-31 12:42

I have personInvolved component. This component has personDetails component. There is a button in personInvolved component. Onclick of the button I need to append the person

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-31 13:05

    Use *ngFor:

        
        
    

    And in the component code:

        persons: Array = [];
    
        addPerson() {
            this.persons.push(new Person());
        } 
    

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