插入新行时刷新离子列表

时间:2016-01-12 22:50:27

标签: javascript ionic-framework ionic

我正在尝试向Ion-List添加一个新项目,由于某种原因它永远不会刷新以更新列表:

.controller("HomeController",function($scope,$ionicModal,$state){

    $scope.windows = [{id : 1,title:"hello"}];

    $scope.addNewWindow = function(window) {
      // assign a new id to the window
      $scope.windows.push(window);
      // close the modal
      $scope.closeAddNewWindowModal();
    }

我已经调试了它并且$ scope.windows已经更新,它确实显示了多个项目但是由于某些原因,离子列表永远不会更新。

这是Index.html代码:

<body ng-app="starter" ng-controller="HomeController">

    <ion-pane>
      <ion-header-bar class="bar-positive">
        <h1 class="title">MI</h1>

        <div class="buttons">
          <button ng-click="openAddNewWindowModal()" class="button">Add New Window</button>
        </div>
      </ion-header-bar>

      <ion-nav-view class="has-header"></ion-nav-view>

    </ion-pane>

  </body>

list.html看起来像这样:

<ion-list>
  <ion-item ui-sref="window-details" ng-repeat="window in windows">
    {{window.title}}
  </ion-item>
</ion-list>

列表通过ion-nav-view注入,如下所示:

 <ion-pane>
      <ion-header-bar class="bar-positive">
        <h1 class="title">MI</h1>

        <div class="buttons">
          <button ng-click="modal.show()" class="button">Add New Window</button>
        </div>
      </ion-header-bar>

      <ion-nav-view class="has-header"></ion-nav-view>

    </ion-pane>

0 个答案:

没有答案