对象值不持久

Object values not persisting

http://plnkr.co/edit/KEhcaEs2GptBlF60KAXi?p=preview

我正在尝试创建一个手风琴,每组都有多个选项。 一旦在组中创建了一个 selection,它下面的组将被启用并扩展以允许下一个 selection。 我让 UI 工作,但是当我存储 selection 时,每次我 select 东西时它都会被覆盖。

如何保留 selected 值?

angular.module('ui.bootstrap.demo', ['ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('AccordionDemoCtrl', function ($scope) {

    $scope. oneAtATime = true;

    $scope.selectedCar = {
        make: null,
        model: null,
        year: null,
        comments: null
    }

    $scope.setSelectedCar = function (key, value) {
        $scope.selectedCar[key] = value;
    }

    $scope.status = {
        isFirstOpen: true,
        isFirstDisabled: false
    };

    $scope.cars = {};
  });

您的价值观不持久的原因是它们被覆盖了:

<accordion-group heading="Model" is-open="selectedCar.make" is-disabled="!selectedCar.make">

手风琴关闭后,属性 is-open="selectedCar.make" 实际上会将 selectedCar.make 设置为 false

所有其他值也是如此。

这是一个有效的 plunker。 (还包含对其他一些问题的修复,例如 selectedCar 的不适当数据绑定等等...)