我使用AngularJS 1和onsen框架来开发应用程序,我尝试了以下示例:
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模块并加载了它,但它没有工作。
任何提示?