VGM
VGM

Reputation: 1

AngularJs - Dynamic rows in table

I have two table, table 1 and table 2.. Table 1 has a field count. based on the count value(count value= no of rows populated), rows should be automatically populated in table 2. I am new to angularjs. Please let me know how can acheive this

Upvotes: 0

Views: 77

Answers (2)

FvB
FvB

Reputation: 723

You can use things such the ngIf, ngShow and ngHide directive to hide or show DOM objects based on an expression, or use ngRepeat to dynamically add additional DOM object based on a growing or shrinking array in your controller.

My guess is you're looking for an visibility directive, so I think the following might help:

<table id="table1">
    <tr data-ng-repeat="row in table1">
        <td>{{row.someData}}</td>
    </tr>
</table>

<table id="table2" data-ng-show="table1.length == 0">
    <tr data-ng-repeat="row in table2">
        <td>{{row.someData}}</td>
    </tr>
</table>

Note that both tables are filled with an ngRepeat by using corresponding arrays from your controller as a source. On the second table, you can see an ngShow directive with an expression that says: "if table1 is empty, show me".

I hope this helps.

Upvotes: 0

Nirmal Borkar
Nirmal Borkar

Reputation: 126

To render values in your table you can use ng-repeat directive.

Upvotes: 1

Related Questions