Как переключать строки в угловых, чтобы развернуть или свернуть ряд, как в аккордеоне?

0

не могли бы вы рассказать мне, как переключать строки в угловом. Иными словами, я сделал один простой проект сбрасываемого примера строки в угловом, он будет расширяться, когда пользователь нажимает строку так же, как в Аккордеоне. Так что моя проблема в том, что когда я нажимаю на первую строку, открыть или расширить третий ряд почему? только первая строка будет расширяться.. можем ли мы добавить какой-то переход линейки в том, что он выглядит как слайд вверх и слайд вниз.

нажмите первую строку, чтобы расширить третью строку, почему?

<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">

    <title>Ionic Swipe Down</title>

    <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
    <script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>

    <script src="http://code.ionicframework.com/contrib/ionic-contrib-swipecards/ionic.swipecards.js?v=5"></script>
    <script src="script.js"></script>

</head>
<style>
    .bg {
        background: lightgray;
        position: relative;
    }
    .ptag {
        position: absolute;
        top:0;
        left:0;
        width: 7%;
        border: 1px solid red;
        height: 100%;
        background: lightblue;
        color: white;
    }
    .circle{
        width: 50px;
        height: 50px;
        float: right;
        border-radius: 100%;
        background: green;
        margin-top: -7%;
        line-height: 50px;
        text-align: center;
        color:black!important;
    }
</style>
<body ng-app="app">
<div ng-controller="apptes">
<div class="list card">

    <div class="item item-avatar bg"  ng-click="clickrow()" ng-repeat="n in obj">
       <p class="ptag">P</p>
        <h2>{{n.number}}</h2>
        <p>{{n.name}}</p>
        <p class="circle">650</p>
    </div>
<div ng-show="toogle_item">
    <div class="item item-body" >

        <p>
            This is a "Facebook" styled Card. The header is created from a Thumbnail List item,
            the content is from a card-body consisting of an image and paragraph text. The footer
            consists of tabs, icons aligned left, within the card-footer.
        </p>
        <p>
            <a href="#" class="subdued">1 Like</a>
            <a href="#" class="subdued">5 Comments</a>
        </p>
    </div>

    <div class="item tabs tabs-secondary tabs-icon-left">
        <a class="tab-item" href="#">
            <i class="icon ion-thumbsup"></i>
            Like
        </a>
        <a class="tab-item" href="#">
            <i class="icon ion-chatbox"></i>
            Comment
        </a>
        <a class="tab-item" href="#">
            <i class="icon ion-share"></i>
            Share
        </a>
    </div>
</div>
</div>
</div>

</body>
</html>

можем ли мы добавить слайд вверх и скользить в этом замедленном движении?

Теги:
ionic-framework
angularjs-scope
angularjs-directive
angularjs-ng-repeat

1 ответ

2

Вот что вы хотите или, по крайней мере, стартовый макет:

HTML:

<html ng-app="ionicApp">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>Ionic Accordion</title>

    <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
    <script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>

  </head>

  <body ng-controller="MyCtrl">

    <ion-header-bar class="bar-positive">
      <h1 class="title">Accordion List</h1>
    </ion-header-bar>

    <ion-content>

      <ion-list>
        <div ng-repeat="group in groups">
          <ion-item class="item-stable"
                    ng-click="toggleGroup(group)"
                    ng-class="{active: isGroupShown(group)}">
              <i class="icon" ng-class="isGroupShown(group) ? 'ion-minus' : 'ion-plus'"></i>
            &nbsp;
            Group {{group.name}}
          </ion-item>
          <ion-item class="item-accordion"
                    ng-repeat="item in group.items"
                    ng-show="isGroupShown(group)">
            {{item}}
          </ion-item>
        </div>
      </ion-list>

    </ion-content>

  </body>
</html>

JS:

angular.module('ionicApp', ['ionic'])

.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;
  };

});

CSS:

body {
  cursor: url('http://ionicframework.com/img/finger.png'), auto;
}

/*
 * http://docs.angularjs.org/api/ng/directive/ngShow#usage_animations
 */
.list .item.item-accordion {
  line-height: 38px;
  padding-top: 0;
  padding-bottom: 0;
  transition: 0.09s all linear;
}
.list .item.item-accordion.ng-hide {
  line-height: 0px;
}
.list .item.item-accordion.ng-hide-add,
.list .item.item-accordion.ng-hide-remove {
  display: block !important;
}

Код Pen: http://codepen.io/ionic/pen/uJkCz

Ещё вопросы

Сообщество Overcoder
Наверх
Меню