我有以下代码,可以为法庭创建日历条目列表。每个案件都有一个“状态”下拉列表,由听众在听证会结束后设定。我需要将此信息保存到数据库中。我添加了ng-change,它启动了我要求的功能。但是,如何获取触发ng-change的“status”下拉列表的选定值?
我的观点代码如下:
<div ng-controller="CaseListCtrl">
<div class="row" ng-show="$parent.loggedin">
<div class="col-sm-12 calselectrow">
<div class="inner-addon left-addon">
<span class="glyphicon glyphicon-calendar calicon"></span>
<input type="text" id="calpick" ng-model="date" jdatepicker />
<i class="glyphicon glyphicon-calendar calclick"></i>
<a href="#" class="btn btn-primary flat-edge">>></a>
<span class="bluedept">Department:</span>
<select class="selectpicker deptpicker" id="deptSelect" selectpicker data-ng-model="department" ng-change="getCalendar();">
<option ng-repeat="department in departments">{{department.CourtRoom}}</option>
</select>
</div>
</div>
</div>
<div class="row" ng-show="$parent.loggedin">
<div>
<div class="col-sm-8 col-sm-offset-2 caselist" ng-model="cases" ng-repeat-start="case in cases | orderBy: ['sequence', 'AmPm', 'Sched_Time', 'Case_Number']">
<div class="sequence">
<input type=text class="seq-box" size="1" value="{{case.SeqNumber}}" />
<!-- Add hidden field to hold the CalendarID value for updating the sequence later-->
<input type="hidden" name="CalendarID_{{case.Case.CaseNumber}}" value="{{case.DailyEventCaseID}}" />
</div>
<div class="casetitle">
<span class="caselink">{{case.Case.CaseNumber}}</span>
<a href="calendar" data-toggle="tooltip" data-placement="top" title="Calendar" class="btn btn-xs btn-danger calicon-view" tooltip>
<span class="glyphicon glyphicon-calendar"></span>
</a>
<a href="documents/{{case.Case.CaseNumber}}" data-toggle="tooltip" data-placement="top" title="Documents" class="btn btn-xs btn-danger calicon-view" tooltip>
<span class="glyphicon glyphicon-file"></span>
</a>
<a href="parties/{{case.Case.CaseNumber}}" data-toggle="tooltip" data-placement="top" title="Parties" class="btn btn-xs btn-danger calicon-view" tooltip>
<span class="glyphicon glyphicon-user"></span>
</a>
<select class="form-control input-mini" id="caseStatus" name="caseStatus" ng-model="case.StatusID" ng-change="setItem(case.DailyEventCaseID, case.Case.CaseNumber, case.EventDate, 'STA');" ng-options="caseStatus.Status for caseStatus in caseStatus track by caseStatus.Status" required></select>
{{case.Case.CaseTitle}}
</div>
</div>
<div class="col-sm-8 col-sm-offset-2 caselist-bottom">
<div class="col-sm-9 col-sm-offset-1" ng-repeat="event in case.Events">
<div class="hearing-time">{{case.EventDate | date: 'h:mm a'}}</div>
<div class="hearing-title">{{event.EventName}}</div>
</div>
</div>
<div ng-repeat-end></div>
</div>
</div>
</div>
答案 0 :(得分:0)
事实证明我必须修改ng-options
。这行代码:
<select class="form-control input-mini" id="caseStatus" name="caseStatus" ng-model="case.StatusID" ng-change="setItem(case.DailyEventCaseID, case.Case.CaseNumber, case.EventDate, 'STA');" ng-options="caseStatus.Status for caseStatus in caseStatus track by caseStatus.Status" required></select>
改为:
<select class="form-control input-mini" id="caseStatus" name="caseStatus" ng-model="case.Status" ng-change="setItem(case.DailyEventCaseID, case.Case.CaseNumber, case.EventDate, 'STA');" ng-options="caseStatus.Status for caseStatus in caseStatus track by caseStatus.Status" required></select>
正确地连接了所有内容并且保存工作。