How to generates dynamically ng-model=“my_{{$index}}” with ng-repeat in AngularJS?

前端 未结 6 641
被撕碎了的回忆
被撕碎了的回忆 2020-11-29 08:16

I would like to ask you if you can give me a hand on this.

I have created a jsfiddle with my problem here. I need to generate dynamically some inputs with ng-model i

6条回答
  •  隐瞒了意图╮
    2020-11-29 08:38

    Is there a reason to generate those field names? Can you treat each field as an object with name and value instead of a string name? (FIDDLE)

    function MainCtrl($scope) {
         $scope.queryList = [
             { name: 'Check Users', fields: [ { name: "Name" },  { name: "Id" } ] },
             { name: 'Audit Report', fields: [] },
             { name: 'Bounce Back Report', fields: [ { name: "Date" } ] } 
          ];
    }
    

    And just repeat off of selectedQuery.fields:

    
        {{field.name}}:
        
    
    

提交回复
热议问题