0

enter image description hereI have list that I need to traverse in using angular js. I want to create row dynamically with two column and each column should show different element(record) info from list.

6
  • Please provide some sample code if possible. Commented Jul 29, 2017 at 17:16
  • Yes, at least the list you are referring to Commented Jul 29, 2017 at 17:24
  • if i understand needs each row of your list be the columns, provide the list please Commented Jul 29, 2017 at 17:28
  • List:{Name:Ajay,CaseId:1555,Date:07/13/2017},{Name:Atul,CaseId:16789,Date:09/08/2016} I want to display all info for Ajay in one column and all info for Atul in other column Commented Jul 29, 2017 at 20:39
  • List is an array of objects? Commented Jul 29, 2017 at 21:46

4 Answers 4

1

You can use ng-repeat directive to traverse list item. Which means whenever you want to push element in DOM, do push it inside collection listItems, ng-repeat will take care of rest.

<table>
   <tr ng-repeat="item in listItems">
     <td>{{item.property1}}</td>
     <td>{{item.property2}}</td>
   </tr>
</table>
Sign up to request clarification or add additional context in comments.

2 Comments

my pleasure, but why :( ?
I am getting records from db which will have name,caseid,closed date,other info for each user.I am using ionic framework
0

in controller have your list-array

vm.myList = [{key:'value', key2: 'value2'}, {key:'value', key2: 'value2'}];

in html use the directive ng-repeat to iterate over the array

<table>
   <tbody>
     <th>Key</th>
     <th>Key2</th>
   </tbdoy>
   <tr ng-repeat="item in vm.myList">
       <td>{{item.key}}</td>
       <td>{{item.key2}}</td>
   </tr>
</table>

if wann to add more rows in controller push it to the array

vm.myList.push({key:'newValue', key2:'otherValue'});

Comments

0

Instead of using ng-repeat in tr element , you should use it in td element if you want column based dynamics

Comments

0

It's quite simple...

I created an example.

Plunker link: Click here

Note: I created a dummy example for you. You have to maintain some code according to your array.

14 Comments

what if I want to display firstname and lastname in one column and other frstname and lastname in another column
Then place ng-repeat on <td></td> tag.
scenario is my row should be add dynamically and there will be always two column. there will only two records in one row
please post your array or object (data) so that we can give you best solution.
Array=[{Name:Ajay,CaseId:1555,Date:07/13/2017},{Name:Atul,CaseId:16789,Date:09/08/2017},{Name:Ram,CaseId:16722,Date:05/04/2016}, {Name:Atul,CaseId:16789,Date:09/08/2016} ]
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.