当模型改变时,不能得到局部刷新

Can't get partial to refresh when model changes

本文关键字:局部 刷新 不能 模型 改变      更新时间:2023-09-26

我有一个下拉菜单,填充了以下代码:

<span class="bluedept">Department:</span>
            <select class="selectpicker deptpicker" selectpicker ng-model="department" ng-controller="CaseListCtrl" ng-change="getCalendar();">
                <option ng-repeat="department in departments track by $index">{{department.CourtRoom}}</option>
            </select>

然后在我的控制器中有这个:

JBenchApp.controller('CaseListCtrl', ['$scope', '$http', 
  function ($scope, $http) {
      // Case list stuff here
      $scope.getCalendar = function () {
          var e = document.getElementById("deptSelect");
          var department = e.options[e.selectedIndex].text;
          console.log(department);
          $http.get('http://10.34.34.46/BenchViewServices/api/Calendar/LA/' + department + '/08-27-2015').success(function (response) {
              $scope.cases = response;
          });
      }
          $http.get('http://10.34.34.46/BenchViewServices/api/CourtDept/LA').success(function (response) {
              $scope.departments = response;
          });

  }]);

美元范围。case使用新数据进行更新,但是局部并不进行相应的更改。我怎么做才能使分部视图刷新?

编辑添加部分视图代码:

<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 ng-model="department" ng-controller="CaseListCtrl" ng-change="getCalendar();">
                <option ng-repeat="department in departments track by $index">{{department.CourtRoom}}</option>
            </select>
        </div>
    </div>
</div>
<div class="row" ng-show="$parent.loggedin">
    <div ng-controller="CaseListCtrl">
        <div class="col-sm-8 col-sm-offset-2 caselist" ng-repeat-start="case in cases track by $index">
            <div class="sequence">
                <input type=text class="seq-box" size="1" value="{{case.sequence}}" />
            </div>
            <div class="casetitle">
                <span class="caselink">{{case.Case_Number}}</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_Number}}" 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_Number}}" data-toggle="tooltip" data-placement="top" title="Parties" class="btn btn-xs btn-danger calicon-view" tooltip>
                    <span class="glyphicon glyphicon-user"></span>
                </a>
                {{case.Case_Title}}
            </div>
        </div>
        <div class="col-sm-8 col-sm-offset-2 caselist-bottom">
            <div class="col-sm-9 col-sm-offset-1">
                <div class="hearing-time">{{case.Sched_Time}}&nbsp;{{case.AmPm}}</div>
                <div class="hearing-title">{{case.Event}}</div>
            </div> 
        </div>
        <div ng-repeat-end></div>
    </div>
</div>

尝试按id跟踪案例或从ng-repeat中删除track by。

ng-repeat not update model with track by

更新:

我认为问题是你在html中使用ng-controller两次,导致创建第二个作用域。

将你的html包裹在一个容器div中,并仅对其应用ng-controller属性。