动态模型中的自动填充字段未提交

土生土长的

我需要在动态创建的表单中使用文本输入字段的值填充对象的帮助。在我的控制器中,我声明了 $scope.models={}。下面表单中具有默认值的最后一个输入字段g.quant1由来自服务器的值填充,但在提交表单后,该值不会被传递。以这种方式查看对象{{models | json}}显示为空,如果输入了值,它只会提交最后一个输入值,然后模型才会填充该值

     <div class="list" ng-repeat="g in dcs | filter:{age:'26'}">
            <div class="item item-input item-stacked-label">
             {{g.zidname}} </br>L: <input type="text" id="lll{{$index}}"  ng-model="models['l' + $index]"  name="lf{{u.gidname}}"><p>{{$index}}</p>
               </br>B: <input type="text" id="bbb{{$index}}"  ng-model="models['b' + $index]"  name="bf{{y.gidname}}">
               <!--<p>data.b{{$index}}</p>-->
               </br>D: <input type="text" id="ddd{{$index}}"  ng-model="models['d' + $index]"  name="df{{d.gidname}}">
                 <!--<p>data.d{{$index}}</p>-->
               </br>NUM: <input type="text" id="nummm{{$index}}" ng-model="models['num' + $index]"   name="numf{{y.gidname}}">

               </br>Certified Rate: <input  type="text" id="crrr{{$index}}"  ng-model="models['cr' + $index]"  name="cre{{y.gidname}}">
            <input  type="text"  ng-model="models['quan' + $index]" ng-value="g.quant1" >

             </div>
         </div> 

我的控制器

    $scope.insert50=function(){



  var link = 'http://...';

      $http.post(link, {user: $scope.models

   }).success(function(data){

         alert(data);
      });
  }
亚伯拉罕·格纳辛格

我有一个解决您所有问题的方法,并为解决方案创建了一个单独的plunker我不确定你在做什么name对于每个字段的验证,您需要为其设置唯一性name,并且需要根据您的要求添加requiredng-required属性。在 plunker 中,我包含了最后一个字段的验证,您可以参考。你能检查一下,让我知道一切是否如你所愿?

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章