Showing only html elements which have will get true condition in angular html











up vote
0
down vote

favorite












I have two loop conditions inside my html file




  • the first loop will show some text descriptions


  • the second will be
    the number of boxes based on the the number of descriptions shown in a column



    <tr *ngFor="let view3 of viewProgramDetails3; let ind = index;" style="white-space: pre-wrap;">
    <td>Step {{ ind + 1 }}</td>
    <td style="white-space: pre-wrap;">{{ view3.g_steps }}</td>
    <td>
    <h6>
    <span *ngFor="let item of arrayCbox; let in = index;">
    <ion-item *ngIf="view3.govthirdid == item.checkbox_stepsid">
    <ion-label>{{item.checkbox_stepsid}}</ion-label>
    <ion-checkbox [(ngModel)]="pepperoni"></ion-checkbox>
    </ion-item>
    </span>
    </h6>
    </td>
    </tr>



The output is correct because if there is only 3 description sentences shown, also the checkbox will also show only 3. But the problem if the condition is not true it will create a new line that makes the table larger.



The expected output hopefully would be something like this



step 1 |  description 1 |  checkbox 1
| description 2 | checkbox 2
| description 3 | checkbox 3


but the actual output is like this



step 1 | description 1 | checkbox 1
| description 2 | checkbox 2
| descripttion3 | checkbox 3
| (newline its empty)
| (newline its empty)
| (newline its empty)
| (newline its empty)









share|improve this question




























    up vote
    0
    down vote

    favorite












    I have two loop conditions inside my html file




    • the first loop will show some text descriptions


    • the second will be
      the number of boxes based on the the number of descriptions shown in a column



      <tr *ngFor="let view3 of viewProgramDetails3; let ind = index;" style="white-space: pre-wrap;">
      <td>Step {{ ind + 1 }}</td>
      <td style="white-space: pre-wrap;">{{ view3.g_steps }}</td>
      <td>
      <h6>
      <span *ngFor="let item of arrayCbox; let in = index;">
      <ion-item *ngIf="view3.govthirdid == item.checkbox_stepsid">
      <ion-label>{{item.checkbox_stepsid}}</ion-label>
      <ion-checkbox [(ngModel)]="pepperoni"></ion-checkbox>
      </ion-item>
      </span>
      </h6>
      </td>
      </tr>



    The output is correct because if there is only 3 description sentences shown, also the checkbox will also show only 3. But the problem if the condition is not true it will create a new line that makes the table larger.



    The expected output hopefully would be something like this



    step 1 |  description 1 |  checkbox 1
    | description 2 | checkbox 2
    | description 3 | checkbox 3


    but the actual output is like this



    step 1 | description 1 | checkbox 1
    | description 2 | checkbox 2
    | descripttion3 | checkbox 3
    | (newline its empty)
    | (newline its empty)
    | (newline its empty)
    | (newline its empty)









    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have two loop conditions inside my html file




      • the first loop will show some text descriptions


      • the second will be
        the number of boxes based on the the number of descriptions shown in a column



        <tr *ngFor="let view3 of viewProgramDetails3; let ind = index;" style="white-space: pre-wrap;">
        <td>Step {{ ind + 1 }}</td>
        <td style="white-space: pre-wrap;">{{ view3.g_steps }}</td>
        <td>
        <h6>
        <span *ngFor="let item of arrayCbox; let in = index;">
        <ion-item *ngIf="view3.govthirdid == item.checkbox_stepsid">
        <ion-label>{{item.checkbox_stepsid}}</ion-label>
        <ion-checkbox [(ngModel)]="pepperoni"></ion-checkbox>
        </ion-item>
        </span>
        </h6>
        </td>
        </tr>



      The output is correct because if there is only 3 description sentences shown, also the checkbox will also show only 3. But the problem if the condition is not true it will create a new line that makes the table larger.



      The expected output hopefully would be something like this



      step 1 |  description 1 |  checkbox 1
      | description 2 | checkbox 2
      | description 3 | checkbox 3


      but the actual output is like this



      step 1 | description 1 | checkbox 1
      | description 2 | checkbox 2
      | descripttion3 | checkbox 3
      | (newline its empty)
      | (newline its empty)
      | (newline its empty)
      | (newline its empty)









      share|improve this question















      I have two loop conditions inside my html file




      • the first loop will show some text descriptions


      • the second will be
        the number of boxes based on the the number of descriptions shown in a column



        <tr *ngFor="let view3 of viewProgramDetails3; let ind = index;" style="white-space: pre-wrap;">
        <td>Step {{ ind + 1 }}</td>
        <td style="white-space: pre-wrap;">{{ view3.g_steps }}</td>
        <td>
        <h6>
        <span *ngFor="let item of arrayCbox; let in = index;">
        <ion-item *ngIf="view3.govthirdid == item.checkbox_stepsid">
        <ion-label>{{item.checkbox_stepsid}}</ion-label>
        <ion-checkbox [(ngModel)]="pepperoni"></ion-checkbox>
        </ion-item>
        </span>
        </h6>
        </td>
        </tr>



      The output is correct because if there is only 3 description sentences shown, also the checkbox will also show only 3. But the problem if the condition is not true it will create a new line that makes the table larger.



      The expected output hopefully would be something like this



      step 1 |  description 1 |  checkbox 1
      | description 2 | checkbox 2
      | description 3 | checkbox 3


      but the actual output is like this



      step 1 | description 1 | checkbox 1
      | description 2 | checkbox 2
      | descripttion3 | checkbox 3
      | (newline its empty)
      | (newline its empty)
      | (newline its empty)
      | (newline its empty)






      javascript angular html5 ionic3






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 9 at 8:32









      Julien

      8921026




      8921026










      asked Nov 9 at 8:16









      nyx97

      1118




      1118
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          Try to make your entire <td> conditional :



          <tr *ngFor="let view3 of viewProgramDetails3; let ind = index;" style="white-space: pre-wrap;">
          <td>Step {{ ind + 1 }}</td>
          <td style="white-space: pre-wrap;">{{ view3.g_steps }}</td>
          <ng-container *ngFor="let item of arrayCbox; let in = index;">
          <td *ngIf="view3.govthirdid == item.checkbox_stepsid">
          <h6>
          <ion-item>
          <ion-label>{{item.checkbox_stepsid}}</ion-label>
          <ion-checkbox [(ngModel)]="pepperoni"></ion-checkbox>
          </ion-item>
          </h6>
          </td>
          </ng-container>
          </tr>





          share|improve this answer

















          • 1




            this will create another column in a table if the condition is true, i want it vertically increment. though this is correct from the expected output
            – nyx97
            Nov 9 at 8:40












          • this is the answer i just wrap the ion item inside ion-grid
            – nyx97
            Nov 9 at 8:48


















          up vote
          0
          down vote













          Instead of placing the *ngFor on the <span> put it on a <ng-container>:



          <ng-container *ngFor="let item of arrayCbox; let in = index;">
          <span *ngIf="view3.govthirdid == item.checkbox_stepsid">
          <ion-item>
          <ion-label>{{item.checkbox_stepsid}}</ion-label>
          <ion-checkbox [(ngModel)]="pepperoni"></ion-checkbox>
          </ion-item>
          </span>
          </ng-container>


          The ng-container is an angular specific container element which has no output after rendering






          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%2f53222030%2fshowing-only-html-elements-which-have-will-get-true-condition-in-angular-html%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote



            accepted










            Try to make your entire <td> conditional :



            <tr *ngFor="let view3 of viewProgramDetails3; let ind = index;" style="white-space: pre-wrap;">
            <td>Step {{ ind + 1 }}</td>
            <td style="white-space: pre-wrap;">{{ view3.g_steps }}</td>
            <ng-container *ngFor="let item of arrayCbox; let in = index;">
            <td *ngIf="view3.govthirdid == item.checkbox_stepsid">
            <h6>
            <ion-item>
            <ion-label>{{item.checkbox_stepsid}}</ion-label>
            <ion-checkbox [(ngModel)]="pepperoni"></ion-checkbox>
            </ion-item>
            </h6>
            </td>
            </ng-container>
            </tr>





            share|improve this answer

















            • 1




              this will create another column in a table if the condition is true, i want it vertically increment. though this is correct from the expected output
              – nyx97
              Nov 9 at 8:40












            • this is the answer i just wrap the ion item inside ion-grid
              – nyx97
              Nov 9 at 8:48















            up vote
            1
            down vote



            accepted










            Try to make your entire <td> conditional :



            <tr *ngFor="let view3 of viewProgramDetails3; let ind = index;" style="white-space: pre-wrap;">
            <td>Step {{ ind + 1 }}</td>
            <td style="white-space: pre-wrap;">{{ view3.g_steps }}</td>
            <ng-container *ngFor="let item of arrayCbox; let in = index;">
            <td *ngIf="view3.govthirdid == item.checkbox_stepsid">
            <h6>
            <ion-item>
            <ion-label>{{item.checkbox_stepsid}}</ion-label>
            <ion-checkbox [(ngModel)]="pepperoni"></ion-checkbox>
            </ion-item>
            </h6>
            </td>
            </ng-container>
            </tr>





            share|improve this answer

















            • 1




              this will create another column in a table if the condition is true, i want it vertically increment. though this is correct from the expected output
              – nyx97
              Nov 9 at 8:40












            • this is the answer i just wrap the ion item inside ion-grid
              – nyx97
              Nov 9 at 8:48













            up vote
            1
            down vote



            accepted







            up vote
            1
            down vote



            accepted






            Try to make your entire <td> conditional :



            <tr *ngFor="let view3 of viewProgramDetails3; let ind = index;" style="white-space: pre-wrap;">
            <td>Step {{ ind + 1 }}</td>
            <td style="white-space: pre-wrap;">{{ view3.g_steps }}</td>
            <ng-container *ngFor="let item of arrayCbox; let in = index;">
            <td *ngIf="view3.govthirdid == item.checkbox_stepsid">
            <h6>
            <ion-item>
            <ion-label>{{item.checkbox_stepsid}}</ion-label>
            <ion-checkbox [(ngModel)]="pepperoni"></ion-checkbox>
            </ion-item>
            </h6>
            </td>
            </ng-container>
            </tr>





            share|improve this answer












            Try to make your entire <td> conditional :



            <tr *ngFor="let view3 of viewProgramDetails3; let ind = index;" style="white-space: pre-wrap;">
            <td>Step {{ ind + 1 }}</td>
            <td style="white-space: pre-wrap;">{{ view3.g_steps }}</td>
            <ng-container *ngFor="let item of arrayCbox; let in = index;">
            <td *ngIf="view3.govthirdid == item.checkbox_stepsid">
            <h6>
            <ion-item>
            <ion-label>{{item.checkbox_stepsid}}</ion-label>
            <ion-checkbox [(ngModel)]="pepperoni"></ion-checkbox>
            </ion-item>
            </h6>
            </td>
            </ng-container>
            </tr>






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 9 at 8:35









            Julien

            8921026




            8921026








            • 1




              this will create another column in a table if the condition is true, i want it vertically increment. though this is correct from the expected output
              – nyx97
              Nov 9 at 8:40












            • this is the answer i just wrap the ion item inside ion-grid
              – nyx97
              Nov 9 at 8:48














            • 1




              this will create another column in a table if the condition is true, i want it vertically increment. though this is correct from the expected output
              – nyx97
              Nov 9 at 8:40












            • this is the answer i just wrap the ion item inside ion-grid
              – nyx97
              Nov 9 at 8:48








            1




            1




            this will create another column in a table if the condition is true, i want it vertically increment. though this is correct from the expected output
            – nyx97
            Nov 9 at 8:40






            this will create another column in a table if the condition is true, i want it vertically increment. though this is correct from the expected output
            – nyx97
            Nov 9 at 8:40














            this is the answer i just wrap the ion item inside ion-grid
            – nyx97
            Nov 9 at 8:48




            this is the answer i just wrap the ion item inside ion-grid
            – nyx97
            Nov 9 at 8:48












            up vote
            0
            down vote













            Instead of placing the *ngFor on the <span> put it on a <ng-container>:



            <ng-container *ngFor="let item of arrayCbox; let in = index;">
            <span *ngIf="view3.govthirdid == item.checkbox_stepsid">
            <ion-item>
            <ion-label>{{item.checkbox_stepsid}}</ion-label>
            <ion-checkbox [(ngModel)]="pepperoni"></ion-checkbox>
            </ion-item>
            </span>
            </ng-container>


            The ng-container is an angular specific container element which has no output after rendering






            share|improve this answer

























              up vote
              0
              down vote













              Instead of placing the *ngFor on the <span> put it on a <ng-container>:



              <ng-container *ngFor="let item of arrayCbox; let in = index;">
              <span *ngIf="view3.govthirdid == item.checkbox_stepsid">
              <ion-item>
              <ion-label>{{item.checkbox_stepsid}}</ion-label>
              <ion-checkbox [(ngModel)]="pepperoni"></ion-checkbox>
              </ion-item>
              </span>
              </ng-container>


              The ng-container is an angular specific container element which has no output after rendering






              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                Instead of placing the *ngFor on the <span> put it on a <ng-container>:



                <ng-container *ngFor="let item of arrayCbox; let in = index;">
                <span *ngIf="view3.govthirdid == item.checkbox_stepsid">
                <ion-item>
                <ion-label>{{item.checkbox_stepsid}}</ion-label>
                <ion-checkbox [(ngModel)]="pepperoni"></ion-checkbox>
                </ion-item>
                </span>
                </ng-container>


                The ng-container is an angular specific container element which has no output after rendering






                share|improve this answer












                Instead of placing the *ngFor on the <span> put it on a <ng-container>:



                <ng-container *ngFor="let item of arrayCbox; let in = index;">
                <span *ngIf="view3.govthirdid == item.checkbox_stepsid">
                <ion-item>
                <ion-label>{{item.checkbox_stepsid}}</ion-label>
                <ion-checkbox [(ngModel)]="pepperoni"></ion-checkbox>
                </ion-item>
                </span>
                </ng-container>


                The ng-container is an angular specific container element which has no output after rendering







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 9 at 8:30









                PierreDuc

                27.7k45173




                27.7k45173






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53222030%2fshowing-only-html-elements-which-have-will-get-true-condition-in-angular-html%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

                    Schultheiß

                    Verwaltungsgliederung Dänemarks

                    Liste der Kulturdenkmale in Wilsdruff