如何在angularjs中添加和删除元素 [英] How to add and remove elements in angularjs
问题描述
当我点击Rooms上的+按钮时,我正在尝试添加更多Adult和Child选择元素。当我点击 - 按钮时,我想删除它们,就像我添加它们一样。我还希望它们具有与加载页面时存在的当前Adult和Child元素相同的功能。
我已经包含了我的Codepen。
Codepen [ ^ ]
我的尝试:
我试图使用jQuery,但我不认为其良好的同时使用jQuery和AngularJS时,它可以只使用AngularJS
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) {
这篇关于如何在angularjs中添加和删除元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!