angularjs动态表单字段未定义范围

时间:2016-08-23 00:39:03

标签: angularjs dynamicform

您好我已经这样做了添加动态表单字段

    <div ng-repeat="wspVdcMuniTbl in wspVdcMuniTbls">
        <div class="col-sm-5">
            <label>VDC/Municipalities</label>
            <select 
              ng-model="wspVdcMuniTbl.tbl_vdc_municipality_id[$index]" 
              options="municipalities"
              ng-options="municipality.id as municipality.name for municipality in municipalities">
            </select>
        </div>

        <div class="col-sm-5">
            <label>Wards</label>
            <input type="text"
                ng-model="wspVdcMuniTbl.wards[$index]"
                id="Location">
        </div>

        <div class="col-sm-2">
            <label>&nbsp;</label>
            <button ng-hide="$first" ng-click="removeServiceArea($index)">-</button>
        </div>

</div>

<div class="col-sm-2">
 <button ng-click="addServiceArea()">+</button>

我的js部分是

$scope.wspVdcMuniTbls = [{}];  
  $scope.addServiceArea = function(){        
        $scope.wspVdcMuniTbls.push({});
    }

    $scope.removeServiceArea = function(index){
        $scope.wspVdcMuniTbls.splice(index,1);
    }

这里添加动态表单字段工作正常但提交后console.log($ scope.wspVdcMuniTbl)未定义会有什么问题请帮忙

0 个答案:

没有答案