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)
javascript angular html5 ionic3
add a comment |
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)
javascript angular html5 ionic3
add a comment |
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)
javascript angular html5 ionic3
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
javascript angular html5 ionic3
edited Nov 9 at 8:32
Julien
8921026
8921026
asked Nov 9 at 8:16
nyx97
1118
1118
add a comment |
add a comment |
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>
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
add a comment |
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
add a comment |
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>
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
add a comment |
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>
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
add a comment |
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>
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>
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
add a comment |
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
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Nov 9 at 8:30
PierreDuc
27.7k45173
27.7k45173
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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