0

I am trying to use dynamic ng-model for multilingual data entry. Here is my tabset:

<tabset> <tab ng-repeat="language in languages" heading="{{language}}"> <input type="text" data-ng-model="name[language]" id="name[language]" class="form-control" > </tab> </tabset> 

But it gives error. How can I use it?

Here is the plunker:

Plunker Code

6
  • can you please create plunker? Commented May 5, 2014 at 20:54
  • Is data-ng-model an angular directive? I thought all angular directives were prefixed with ng? Wouldn't it just be ng-model? Commented May 5, 2014 at 21:05
  • 1
    @pje, the data- is an html5 prefix for attributes. developer.mozilla.org/en-US/docs/Web/Guide/HTML/… Commented May 5, 2014 at 21:22
  • @pje I use it to make sure that my code validates. Commented May 5, 2014 at 21:22
  • 1
    declaring $scope.name = [] seems to work? Commented May 5, 2014 at 22:07

2 Answers 2

2

What about declaring $scope.name as an empty object? It seems like it makes the error disappear.

Sign up to request clarification or add additional context in comments.

Comments

0

You can declare an empty array in your controller as:

$scope.value=[]; 

In your html page you can write this:

<tabset> <tab ng-repeat="language in languages" heading="{{language}}"> <input type="text" data-ng-model=value[$index] id="value[$index]" class="form-control" > </tab> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.