How to add a new Row on Angular Flex-box











up vote
0
down vote

favorite












How do you add a new row while looping through your data set.



<div fxLayout="row" fxLayout.sm="column" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutWrap *ngIf="blogs; else loading;">
<div fxFlex="50" fxFlex.sm="100" fxFlex.xs="100" class="article_card" *ngFor="let blog of blogs">
<mat-card class="example-card">
<img mat-card-image src="{{blog.image_1}}" class="article_image">
<mat-card-content>
<h1 class="article_header">{{blog.title}}</h1>
<p class="article_caption">
{{blog.caption}}
</p>
<span class="article_date">{{blog.created}}, </span><span class="article_read_time">{{blog.read_time}} read</span>
</mat-card-content>
</mat-card>
</div>
</div>


The desired layout is 2 cards on Large and Medium view while having 1 card occupy full width for small and extra-small view.










share|improve this question






















  • Have you tried with *ngFor then what happens?
    – Paresh Gami
    Nov 12 at 5:17










  • @PareshGami It stacks all the cards in one row. While the desired layout should be 2 cards in one Row then start a new row with 2 more cards. How can i make that dynamic?
    – GeoffreyMahugu
    Nov 12 at 13:43















up vote
0
down vote

favorite












How do you add a new row while looping through your data set.



<div fxLayout="row" fxLayout.sm="column" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutWrap *ngIf="blogs; else loading;">
<div fxFlex="50" fxFlex.sm="100" fxFlex.xs="100" class="article_card" *ngFor="let blog of blogs">
<mat-card class="example-card">
<img mat-card-image src="{{blog.image_1}}" class="article_image">
<mat-card-content>
<h1 class="article_header">{{blog.title}}</h1>
<p class="article_caption">
{{blog.caption}}
</p>
<span class="article_date">{{blog.created}}, </span><span class="article_read_time">{{blog.read_time}} read</span>
</mat-card-content>
</mat-card>
</div>
</div>


The desired layout is 2 cards on Large and Medium view while having 1 card occupy full width for small and extra-small view.










share|improve this question






















  • Have you tried with *ngFor then what happens?
    – Paresh Gami
    Nov 12 at 5:17










  • @PareshGami It stacks all the cards in one row. While the desired layout should be 2 cards in one Row then start a new row with 2 more cards. How can i make that dynamic?
    – GeoffreyMahugu
    Nov 12 at 13:43













up vote
0
down vote

favorite









up vote
0
down vote

favorite











How do you add a new row while looping through your data set.



<div fxLayout="row" fxLayout.sm="column" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutWrap *ngIf="blogs; else loading;">
<div fxFlex="50" fxFlex.sm="100" fxFlex.xs="100" class="article_card" *ngFor="let blog of blogs">
<mat-card class="example-card">
<img mat-card-image src="{{blog.image_1}}" class="article_image">
<mat-card-content>
<h1 class="article_header">{{blog.title}}</h1>
<p class="article_caption">
{{blog.caption}}
</p>
<span class="article_date">{{blog.created}}, </span><span class="article_read_time">{{blog.read_time}} read</span>
</mat-card-content>
</mat-card>
</div>
</div>


The desired layout is 2 cards on Large and Medium view while having 1 card occupy full width for small and extra-small view.










share|improve this question













How do you add a new row while looping through your data set.



<div fxLayout="row" fxLayout.sm="column" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutWrap *ngIf="blogs; else loading;">
<div fxFlex="50" fxFlex.sm="100" fxFlex.xs="100" class="article_card" *ngFor="let blog of blogs">
<mat-card class="example-card">
<img mat-card-image src="{{blog.image_1}}" class="article_image">
<mat-card-content>
<h1 class="article_header">{{blog.title}}</h1>
<p class="article_caption">
{{blog.caption}}
</p>
<span class="article_date">{{blog.created}}, </span><span class="article_read_time">{{blog.read_time}} read</span>
</mat-card-content>
</mat-card>
</div>
</div>


The desired layout is 2 cards on Large and Medium view while having 1 card occupy full width for small and extra-small view.







html css angular typescript angular-flex-layout






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 at 21:13









GeoffreyMahugu

215




215












  • Have you tried with *ngFor then what happens?
    – Paresh Gami
    Nov 12 at 5:17










  • @PareshGami It stacks all the cards in one row. While the desired layout should be 2 cards in one Row then start a new row with 2 more cards. How can i make that dynamic?
    – GeoffreyMahugu
    Nov 12 at 13:43


















  • Have you tried with *ngFor then what happens?
    – Paresh Gami
    Nov 12 at 5:17










  • @PareshGami It stacks all the cards in one row. While the desired layout should be 2 cards in one Row then start a new row with 2 more cards. How can i make that dynamic?
    – GeoffreyMahugu
    Nov 12 at 13:43
















Have you tried with *ngFor then what happens?
– Paresh Gami
Nov 12 at 5:17




Have you tried with *ngFor then what happens?
– Paresh Gami
Nov 12 at 5:17












@PareshGami It stacks all the cards in one row. While the desired layout should be 2 cards in one Row then start a new row with 2 more cards. How can i make that dynamic?
– GeoffreyMahugu
Nov 12 at 13:43




@PareshGami It stacks all the cards in one row. While the desired layout should be 2 cards in one Row then start a new row with 2 more cards. How can i make that dynamic?
– GeoffreyMahugu
Nov 12 at 13:43












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Here is how i achieved the desired layout:



<div fxLayout="row wrap" fxLayout.lt-sm="column" fxLayoutGap="15px" fxLayoutAlign=”flex-start” *ngIf="blogs; else loading;">
<ng-container *ngFor="let blog of blogs">
<mat-card fxFlex="0 1 calc(50% - 32px)" class="card_item" fxFlex.lt-sm="100%">
<img mat-card-image src="{{blog.image_1}}" class="article_image">
<mat-card-content>
<h1 class="article_header">{{blog.title}}</h1>
<p class="article_caption">
{{blog.caption}}
</p>
<span class="article_date">{{blog.created}}, </span><span class="article_read_time">{{blog.read_time}} read</span>
</mat-card-content>
</mat-card>
</ng-container>
</div>


For more info please check on this article: AG-GRID: THE BEST HTML5 GRID IN THE WORLD






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53253290%2fhow-to-add-a-new-row-on-angular-flex-box%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Here is how i achieved the desired layout:



    <div fxLayout="row wrap" fxLayout.lt-sm="column" fxLayoutGap="15px" fxLayoutAlign=”flex-start” *ngIf="blogs; else loading;">
    <ng-container *ngFor="let blog of blogs">
    <mat-card fxFlex="0 1 calc(50% - 32px)" class="card_item" fxFlex.lt-sm="100%">
    <img mat-card-image src="{{blog.image_1}}" class="article_image">
    <mat-card-content>
    <h1 class="article_header">{{blog.title}}</h1>
    <p class="article_caption">
    {{blog.caption}}
    </p>
    <span class="article_date">{{blog.created}}, </span><span class="article_read_time">{{blog.read_time}} read</span>
    </mat-card-content>
    </mat-card>
    </ng-container>
    </div>


    For more info please check on this article: AG-GRID: THE BEST HTML5 GRID IN THE WORLD






    share|improve this answer

























      up vote
      0
      down vote













      Here is how i achieved the desired layout:



      <div fxLayout="row wrap" fxLayout.lt-sm="column" fxLayoutGap="15px" fxLayoutAlign=”flex-start” *ngIf="blogs; else loading;">
      <ng-container *ngFor="let blog of blogs">
      <mat-card fxFlex="0 1 calc(50% - 32px)" class="card_item" fxFlex.lt-sm="100%">
      <img mat-card-image src="{{blog.image_1}}" class="article_image">
      <mat-card-content>
      <h1 class="article_header">{{blog.title}}</h1>
      <p class="article_caption">
      {{blog.caption}}
      </p>
      <span class="article_date">{{blog.created}}, </span><span class="article_read_time">{{blog.read_time}} read</span>
      </mat-card-content>
      </mat-card>
      </ng-container>
      </div>


      For more info please check on this article: AG-GRID: THE BEST HTML5 GRID IN THE WORLD






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Here is how i achieved the desired layout:



        <div fxLayout="row wrap" fxLayout.lt-sm="column" fxLayoutGap="15px" fxLayoutAlign=”flex-start” *ngIf="blogs; else loading;">
        <ng-container *ngFor="let blog of blogs">
        <mat-card fxFlex="0 1 calc(50% - 32px)" class="card_item" fxFlex.lt-sm="100%">
        <img mat-card-image src="{{blog.image_1}}" class="article_image">
        <mat-card-content>
        <h1 class="article_header">{{blog.title}}</h1>
        <p class="article_caption">
        {{blog.caption}}
        </p>
        <span class="article_date">{{blog.created}}, </span><span class="article_read_time">{{blog.read_time}} read</span>
        </mat-card-content>
        </mat-card>
        </ng-container>
        </div>


        For more info please check on this article: AG-GRID: THE BEST HTML5 GRID IN THE WORLD






        share|improve this answer












        Here is how i achieved the desired layout:



        <div fxLayout="row wrap" fxLayout.lt-sm="column" fxLayoutGap="15px" fxLayoutAlign=”flex-start” *ngIf="blogs; else loading;">
        <ng-container *ngFor="let blog of blogs">
        <mat-card fxFlex="0 1 calc(50% - 32px)" class="card_item" fxFlex.lt-sm="100%">
        <img mat-card-image src="{{blog.image_1}}" class="article_image">
        <mat-card-content>
        <h1 class="article_header">{{blog.title}}</h1>
        <p class="article_caption">
        {{blog.caption}}
        </p>
        <span class="article_date">{{blog.created}}, </span><span class="article_read_time">{{blog.read_time}} read</span>
        </mat-card-content>
        </mat-card>
        </ng-container>
        </div>


        For more info please check on this article: AG-GRID: THE BEST HTML5 GRID IN THE WORLD







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 at 9:49









        GeoffreyMahugu

        215




        215






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53253290%2fhow-to-add-a-new-row-on-angular-flex-box%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to pass form data using jquery Ajax to insert data in database?

            National Museum of Racing and Hall of Fame

            Guess what letter conforming each word