Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi..
I want to add rows to a table on click of a button(each row would consists of textboxes and dropdown lists) in Angular JS.

I tried everything,I googled for more than a week but could not crack this.
Please help. Its urgent
Posted
Comments
Sergey Alexandrovich Kryukov 5-Jan-16 13:55pm    
Everything? What exactly? What have you tried so far?
—SA
Member 11579819 5-Jan-16 13:59pm    
I tried but everything was complete mess. It's no where around what was supposed to happen. I cannot decide how can I create rows which would consists of textboxes and dropdowns where I have to populate some of them with AJAX.
Sergey Alexandrovich Kryukov 5-Jan-16 14:08pm    
Than write something which is not mess. You just need to add an event handler to a button and the do DOM manipulation. An AngularJS manual should explain it all. Besides, AngularJS contains the tiny jQuery subset. And, finally, this problem is easily solved using native JavaScript without any libraries.
If you don't want to show what have you tried, it's hard to get help for you.
—SA
Member 11579819 5-Jan-16 14:12pm    
There's nothing like I am trying to hide what I have written till now. I always used to post all the codes here in Code Project. But this time I feel like the codes are not sensible and I am too shy to post them. Nevertheless I will try doing something sensible and post it here ASAP. Meanwhile if you can then do think on this.
ZurdoDev 5-Jan-16 14:27pm    
I suggest start by searching for how to dynamically add controls to a page using jquery, since that is really what you are doing.

There are lots of examples.

1 solution

Hi, you can create a collection into your controller and use the ng-repeat directive into a . Then in a click event you can add element to your collection, this generate new rows.

Example

For more complex functionality you must understand the angularjs directives and implement your own directives.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900