|
本帖最后由 sam_rainobw 于 2015-12-31 17:24 编辑
1、目的:
通过点击按钮方式实现每次增加一行记录,其中记录中包含了一个toggle类型的chekbox单选按钮。
2、问题描述:
checkbox单独实现(非动态实现)时,可以取到默认值,但动态实现(通过点击增加按钮实现),如果不对checkbox进行操作,则获取到的值为空(""),如果想获取false结果,必须先选真,再选为假,才能取到值。
请问大能们是否遇到过类似问题,谢谢
附代码:
<ion-view view-title="资产列表">
<ion-content class="scroll-content has-header">
<div ng-controller="qylsCtrl">
<div class="row row-stretch" id="title">
<div class="col" ng-repeat="title in titles"><span>{{title}}</span></div>
</div>
<form name="myForm">
<div id="content" class="row row-wrap" ng-repeat="data in list">
<div class="col">
<label class="item item-select">
<select ng-model="data.asertType">
<option value="">==请选择==</option>
<option value="0">货币资金</option>
<option value="1">应收票据</option>
<option value="2">预付账款</option>
<option value="3">商业服务业</option>
<option value="4">固定资产</option>
<option value="5">固定物资</option>
<option value="6">其他</option>
</select>
</label>
</div>
<div class="col"><input type="text" placeholder="请输入资产名称" ng-model="data.assertName"></div>
<div class="col">
<input name="jine" type="number" placeholder="请输入金额(数字类型)" ng-model="data.amount">
<div ng-messages="myForm.jine.$error" style="color:#803320" ng-messages-include="errors.html"></div>
</div>
<div class="col">
<label class="toggle toggle-balanced">
<input type="checkbox" checked
ng-model="data.ismortgage"
/>
<div class="track">
<div class="handle"></div>
</div>
</label>
</div>
<div class="col">
<input name="rate" type="number" placeholder="请填写抵押比例" ng-model="data.mortgageRate">
<div ng-messages="myForm.rate.$error" style="color:#803320" ng-messages-include="errors.html"></div>
</div>
<div class="col">[<a href ng-click="list.splice($index, 1)">X</a>]</div>
</div>
</form>
<div id="btnid" class="padding-left padding-right">
<button class="button button-stable button-positive" ng-click="add()">增加记录</button>
</div>
</div>
</ion-content>
</ion-view>
<script>
var app=angular.module("assertApp",["ngMessages"]);
app.controller("qylsCtrl", ["$scope","$http",function($scope,$http){
$scope.list = [];
$scope.titles=['资产类型','资产名称','金额','是否抵押','抵押比例(%)',' '];
var fields = ['asertType','assertName','amount','ismortgage','mortgageRate'];
var projectId = '';
projectId = getQueryString('projectid');
var dataName = 'asset_list';
$scope.add=function(){
$scope.data = {};
for(var j=0;j<fields.length;j++){
$scope.data[fields[j]]="";
}
$scope.list.push($scope.data);
};
}]);
</script>
|
|