1

i have a dataTable that i define dynamically, based on my controller's model, as following:

<tbody>
    <tr ng-repeat="rec in grid.records">
        <td ng-repeat="col in grid.columns" 
            ng-init="value=rec[col.name]">
            <span ng-model="rec[col.name]">{{value}}</span>
        </td>
    </tr>
</tbody>

why doesn't dataTable column values is updated when model changes?

7
  • 1
    Why are you using ng-model for a non-input element? Commented Nov 25, 2014 at 18:22
  • Yes-yes, I would advice to read about ngModel: official docs Commented Nov 25, 2014 at 18:23
  • actually, i wasn't using ng-model, but after a few tries, i've tried to use it. Commented Nov 25, 2014 at 18:27
  • anyway, my code without 'ng-model' supposed to work? Commented Nov 25, 2014 at 18:30
  • 1
    From Angular Docs: "The only appropriate use of ngInit is for aliasing special properties of ngRepeat" rec[col.name] is not a special property. An example of a special property would be $index. Commented Nov 25, 2014 at 18:39

1 Answer 1

1

Try this:

<tbody>
    <tr ng-repeat="rec in grid.records">
        <td ng-repeat="col in grid.columns">
            <span>{{rec[col.name]}}</span>
        </td>
    </tr>
</tbody>
Sign up to request clarification or add additional context in comments.

2 Comments

i have created a isolated case, using {{rec[col.name]}} instead of {{value}}, and it works. Thank you very much. If my real application keep not working out, i'll let you know.
the whole problem was how i did use ng-init. Thanks.

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.