且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在angularjs中添加和删除元素

更新时间:2023-12-05 16:06:16

做>
Quote:

当我点击Rooms上的+按钮时,会添加更多Adult和Child选择元素。同样,当我点击房间上的 - 按钮时,我希望删除那些添加的元素





 


scope.minusRoom = function(){
if(


scope.room> 1){


I am trying to add more Adult and Child select elements when I click the + button on Rooms. I want to remove them when I click the - button, just the way I add them. I also want them to have the same functionality as the current Adult and Child elements which are present when the page is loaded.

I have included my Codepen.

Codepen[^]

What I have tried:

I tried using jQuery but I don't think its good to use both jQuery and AngularJS when it can be done using just AngularJS

Quote:

When I click the + button on Rooms, more Adult and Child select elements are added. Similarly, I want those added elements to be removed when I click the - button on rooms





scope.minusRoom = function () { if (


scope.room > 1) {