简体   繁体   English

Angular Material : Md-card 段落中断 ng-repeat

[英]Angular Material : Md-card paragraph break ng-repeat

I'm building this from the angular Material website example, but added a ng-repeat , the list is nice and responsive:我正在从 angular Material 网站示例中构建它,但添加了一个 ng-repeat ,该列表很好且响应迅速:

在此处输入图片说明

There are 6 objects displayed, cause there are 6 in the backend server.显示了 6 个对象,因为后端服务器中有 6 个。

If I resize, instead of passing a line, it makes it narrow, which is not a bad thing:如果我调整大小,而不是通过一条线,它会使它变窄,这不是一件坏事: 在此处输入图片说明

If I resize to the 5" PHONE format, it is ok too:如果我调整为 5" PHONE 格式,也可以:

在此处输入图片说明

Now, I get 20 objects from my server back end, Material won't automatically pass a line each 6 objects, it doesn't display right.现在,我从我的服务器后端获取 20 个对象,Material 不会每 6 个对象自动传递一行,它显示不正确。

So, I've tried this code, but it doesn't work, the ng-if works, but doesn't pass a line.所以,我试过这段代码,但它不起作用,ng-if 起作用,但没有通过一行。 :

<md-content class="md-padding" layout-xs="column" layout="row">
                                  <div  flex-xs flex-gt-xs="50" layout="column" class="flex" ng-repeat="j in juristes" ng-click="editerJuriste(j)" style="cursor:pointer">
                                    <md-card    ng-class="{yellow : j == selectedObject}" ng-click="selectItem(j); selectedIndex = 1;" class="md-card" style="cursor:pointer">
                                        <img ng-src="{{imagePath}}" class="md-card-image" alt="Washed Out"/>
                                        <md-card-title>
                                            <md-card-title-text>
                                            <span class="md-headline">{{ j.text }}</span>
                                            <span class="md-subhead">{{ j.ville }}</span>
                                            </md-card-title-text>
                                        </md-card-title>

                                        <md-card-content>
                                            <p>It is a <a href="#">long established fact</a> that a reader will be distracted by the readable content of a page when looking at its layout.</p>
                                            <h4>More Ipsums</h4>
                                            <p>The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.</p>
                                        </md-card-content>

                                        <md-card-actions layout="row" layout-align="end center">
                                          <md-button class="md-icon-button" aria-label="Favorite">
                                            <md-icon md-svg-icon="img/icons/favorite.svg"></md-icon>
                                          </md-button>
                                          <md-button class="md-icon-button" aria-label="Settings">
                                            <md-icon md-svg-icon="img/icons/menu.svg"></md-icon>
                                          </md-button>
                                          <md-button class="md-icon-button" aria-label="Share">
                                            <md-icon md-svg-icon="img/icons/share-arrow.svg"></md-icon>
                                          </md-button>
                                        </md-card-actions>

                                    </md-card>

                                    <div  ng-if="($index + 1) % 3 == 0">test<div class='md-padding' layout="row" layout-wrap></div><br></div>
                                  </div>
                            </md-content>

Is there any way to keep the CSS behaviour, and to insert a paragraph break, each of the 6 objects?有什么方法可以保持 CSS 行为,并在 6 个对象中的每一个中插入一个分段符?

Thank you a lot if you know about this problem, I've tried a few solutions on StackOverflow, but it doesn't work as expected.非常感谢您知道这个问题,我已经在 StackOverflow 上尝试了一些解决方案,但没有按预期工作。

EDIT : Just to make you see how it can't be used : I 've added a few objects :编辑:只是为了让您了解它是如何无法使用的:我添加了一些对象: 在此处输入图片说明

Bootstrap does this automatically, but i really can't understand how to break a paragraph between objects with material, please help. Bootstrap 会自动执行此操作,但我真的无法理解如何在带有材料的对象之间断开段落,请帮忙。

You can solve the md-card wrapping issue by wrapping the card in a .您可以通过将卡片包装在 .md 文件中来解决 md-card 包装问题。 Repeat the block with the desired flex value (ie flex="20" for rows of 5).使用所需的 flex 值(即 flex="20" 为 5 行)重复块。 Note: It doesn't auto height the cards though.注意:虽然它不会自动调整卡片的高度。 Editing from code pen URL: https://codepen.io/anon/pen/MwzRde从代码笔 URL 编辑: https : //codepen.io/anon/pen/MwzRde

 angular.module('MyApp') .controller('AppCtrl', function($scope) { $scope.users = ['Fabio', 'Leonardo', 'Thomas', 'Gabriele', 'Fabrizio', 'John', 'Luis', 'Kate', 'Max']; });
 .gridListdemoBasicUsage md-grid-list { margin: 8px; } .gridListdemoBasicUsage .gray { background: #f5f5f5; } .gridListdemoBasicUsage md-grid-tile { transition: all 400ms ease-out 50ms; }
 <html> <head> <link rel="stylesheet prefetch" href="https://gitcdn.xyz/repo/angular/bower-material/v0.10.1-rc4/angular-material.css"> </head> <body> <div ng-app="MyApp" class="gridListdemoBasicUsage" ng-controller="AppCtrl as appCtrl"> <h1>User List</h1> <div class='md-padding' layout="row" layout-wrap> <div flex="20" ng-repeat="user in users"> <md-card> <img src="http://placehold.it/150x150" class="md-card-image" alt="user avatar"> <md-card-content> <h2>{{user}}</h2> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</p> </md-card-content> <div class="md-actions" layout="row" layout-align="end center"> <md-button>Save</md-button> <md-button>View</md-button> </div> </md-card> </div> </div> </div> <script src="//static.codepen.io/assets/common/stopExecutionOnTimeout-b2a7b3fe212eaa732349046d8416e00a9dec26eb7fd347590fbced3ab38af52e.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-animate.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-route.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-aria.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-messages.min.js"></script> <script src="https://gitcdn.xyz/repo/angular/bower-material/v0.10.1-rc4/angular-material.js"></script> <script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-114/assets-cache.js"></script> <script> angular.module('MyApp') .controller('AppCtrl', function($scope) { $scope.users = ['Fabio', 'Leonardo', 'Thomas', 'Gabriele', 'Fabrizio', 'John', 'Luis', 'Kate', 'Max']; }); //# sourceURL=pen.js </script> </body> </html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM