我有一个开始日期字段(日期选择器)和一个客户端状态(下拉列表)字段。
如果我在日期选择器中选择日期,则在将日期值传递给服务器时会显示undefined
,但如果我在该字段中键入任何带日期的值,则该确切值将正确发送到服务器。
在下拉列表中,我没有得到它的值undefined
。
我的代码是:
<div class="form-group">
<label for="inputPassword3" class="col-sm-3 control-label">Client Name</label>
<div class="col-sm-9">
<div ng-controller="MyCntrl" >
<select class="form-control" name="clientname" id="clientname" class="form-control" ng-model="vm.clientname" ng-change="change(myColor)" >
<option value="">Select Client Name</option>
<option ng-repeat="color in colors"
value="{{color.value}}"
ng-selected="{{color.value == myColor}}" name="clientname" id="clientname" class="form-control" ng-model="vm.clientname">
{{color.clientname}}
</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-3 control-label">Project Startdate</label>
<div class="col-sm-9">
<!-- <input type="text" name="prjstartdate" id="prjstartdate" class="form-control" ng-model="vm.user.prjstartdate" required />-->
<div class="container" id="sandbox-container">
<div class="input-daterange input-group" id="datepicker" name="prjstartdate" id="prjstartdate" class="form-control" ng-model="vm.prjstartdate">
<input type="text" name="prjstartdate" id="prjstartdate" class="form-control" ng-model="vm.prjstartdate" required />
</div>
</div>
<div class="modal-footer" ng-controller="MyCntrlsave">
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" ng-click="savedetails()">Save changes</button>
</div>
</div>
</div>
js code:
<script type="text/javascript">
function MyCntrlsave($scope,$http) {
$scope.savedetails = function() {
var vm = this;
var projectname=$scope.vm.prjname;
var cilentname=$scope.vm.color;
var clientstatus=$scope.vm.prjsta;
var prjstartdate=$scope.vm.prjstartdate;
var prjenddate=$scope.vm.prjenddate;
var prjurl=$scope.vm.prjurl;
alert("projectname::"+projectname)
alert("prjstartdate::"+prjstartdate)
}
}