<ion-item> 显示模式窗口时中断中的 href



请阅读编辑2,因为它包含更新的错误

我有一个像这样的ng-repeat:

    <ion-list>
        <ion-item ng-repeat="ship in ships" href="#app/ships/{{ship.id}}">
            {{ship}}
        </ion-item>
    </ion-list>

当您第一次加载页面时,离子项href正常工作。向列表中添加新数据时发生错误。href元素停止工作,项目不可点击。刷新页面修复href

添加的新数据正确地显示在列表中,具有正确的字段和值。

这是一个bug还是我必须做些什么来刷新列表?

编辑

我使用SQLite来保存和检索我的数据,也使用工厂包装器在这里找到:https://gist.github.com/jgoux/10738978

添加代码:

要添加新船,我只需打开带有输入字段和提交按钮的模态窗口。

    // Called when the form is submitted
    $scope.createShip = function (ship) {
        shipFactory.saveShip(ship)
            .then(function () {
                $scope.shipModal.hide();
                updateScope();
                $scope.newship = {};
            });
    };

更新作用域

    function updateScope() {
        shipFactory.getAllShips().then(function (ships) {
            $scope.ships = ships;
        });
    }

编辑2 在无法重现柱塞的问题后。我了解到是模态导致了错误。打开然后关闭模态会导致错误(不保存)。

模态代码:

    // Create and load the Modal
    $ionicModal.fromTemplateUrl('new-ship.html', function (modal) {
        $scope.shipModal = modal;
    }, {
        scope: $scope,
        animation: 'slide-in-up'
    });
    // Open our new ship modal
    $scope.newShip = function () {
        $scope.shipModal.show();
    };
    // Close the new ship modal
    $scope.closeNewShip = function () {
        $scope.shipModal.hide();
    };

我试过添加$scope.shipModal.remove();,但链接仍然断开。创建"拖动"事件修复所有链接。例如:将导航菜单拖到视图

经过反复试验,我终于解决了我的问题。虽然我不完全理解为什么这很重要,但错误的发生是因为我放置<button>元素的位置。

如果按钮被放置在<ion-nav-buttons>标签中,则会发生错误。

<!--This doesn't work-->
<ion-nav-buttons side="right">
    <button menu-toggle="right" class="button button-icon icon ion-plus-circled" ng-click="newShip()"></button>
</ion-nav-buttons>

将按钮放置在<ion-content>标签内的任何地方都可以正常工作。

<ion-content class="has-header">
    ...
    <button ng-click="newShip()">New ship</button>
</ion-content>

最新更新