2

我正在使用带有 onsen 框架的 AngularJS 1 来开发应用程序,并且正在尝试以下示例:

代码笔示例

angular.module('myApp', ['onsen', 'ngAnimate']).controller('MyCtrl', function($scope) {
  $scope.groups = [];
  for (var i = 0; i < 10; i++) {
    $scope.groups[i] = {
      name: i,
      items: []
    };
    for (var j = 0; j < 3; j++) {
      $scope.groups[i].items.push(i + '-' + j);
    }
  }

  /*
   * if given group is the selected group, deselect it
   * else, select the given group
   */
  $scope.toggleGroup = function(group) {
    if ($scope.isGroupShown(group)) {
      $scope.shownGroup = null;
    } else {
      $scope.shownGroup = group;
    }
  };
  $scope.isGroupShown = function(group) {
    return $scope.shownGroup === group;
  };

});

在示例中您可以看到,他们在元素上使用了 ng-show 和 ng-hide 函数。

我自己尝试了代码,但无法让列表崩溃,因为 ng-hide 不起作用。

我什至下载了 angular-animate.js 模块并加载了它,但它不起作用。

有小费吗?

4

0 回答 0