Linked Questions

49 votes
4 answers
54k views

*ngIf and *ngFor on <td></td> element [duplicate]

I have a situation where I need *ngIf and *ngFor directive on the same element. I found lot of answers on the stackoverlow but none for the this type of situation. I have a table in which I'm looping ...
Igor Janković's user avatar
31 votes
3 answers
140k views

Apply a condition using ngFor and ngIf in angular 2 [duplicate]

Hi There I have been trying to filter an array with some success using ngIF and ngFor. <button *ngFor="let item of items"> <div *ngIf="(item.data.type == 1)"> {{item.data.name}} </div&...
DN0300's user avatar
  • 876
16 votes
1 answer
19k views

*ngFor and *ngIf together, Angular2, Ionic2 [duplicate]

I am trying to display list of options using ngFor but only fulfilling certain condition, is it possible to use ngFor and ngIf together to achieve that? Something like this: <ion-select [(ngModel)]...
user avatar
5 votes
2 answers
23k views

Using ngIf and ngFor in option [duplicate]

I want to use ngIf and ngFor in one line. I know it is not possible but is there any other method to do this? Here is my code: <option *ngIf="tmpLanguage.id!=languages.id" *ngFor="let ...
C.B.'s user avatar
  • 310
6 votes
3 answers
28k views

Can't use *ngIF inside *ngFor : angular2 [duplicate]

i'm using angular2 and i'im binding data from a service , the probleme is when i'm loading data i should filter it by an id , , this is what i'm supposed to do : <md-radio-button *ngFor="#...
firasKoubaa's user avatar
  • 6,739
4 votes
1 answer
7k views

Nested *ngFor* with *ngIf [duplicate]

Problem In the following code, I'm trying to display all Projects ( Objects ) under the Tab they're meant to go based on their category. Category has to be equivalent. EDIT: If that's not clear, ...
johnchar's user avatar
  • 547
11 votes
1 answer
15k views

Angular 2 - Two structural directives on the same DOM element [duplicate]

While playing around with Angular 2, I've encountered a problem: apparently I can't put two structural directives (ngFor, ngIf) on the same DOM element. In Angular 1 this used to work. For example: &...
Yaron Schwimmer's user avatar
1 vote
2 answers
12k views

*ngIf and *ngFor on same element [duplicate]

I have a problem when I use *ngFor and *ngIf on the same element. <div *ngFor="let recipeStep of RecipeSteps; let i = index" *ngIf="position === i"> {{ recipeStep }} </div>...
Amjed Omar's user avatar
1 vote
1 answer
6k views

Angular2 equivalent of ng-repeat with ng-if? [duplicate]

I have been trying out Ionic 2 along with angular 2 and its grid layout system. I'd like to be able to loop through an array of items, but because I want it to be responsive, I need to put every X ...
lateAtNight's user avatar
2 votes
1 answer
2k views

Angular 2 ngIf and ngFor combination [duplicate]

I am wondering if I have a combination of ngIf and ngFor like this. What will run first when Angular creates its elements? <li *ngIf='isDisplayed' *ngFor='let item of itemsList'></li> ...
Pho Huynh's user avatar
  • 1,537
0 votes
1 answer
3k views

Can't have multiple template bindings on one element. ngFor and ngIf together [duplicate]

I'm trying to get the li element to display {{info.email}} USER ON THIS DEVICE only if localStorage variable matches.I need it inside the li element as this data is coming from the database. Can ...
hayonj's user avatar
  • 1,439
4 votes
1 answer
597 views

Can't combine *ngFor and *ngIf [duplicate]

I have a need to bind an *ngFor loop to a div, but I also need to only display it after meeting an *ngIf condition. But Angular 4 won't let you combine them. My code: <ion-item class="item-icon-...
cnak2's user avatar
  • 1,771
1 vote
2 answers
1k views

Angular 4: Using ngIf and ngFor for the same field within ngFor [duplicate]

I am new to Angular 4 and I am stuck in an issue in my code. Below is my code: JSON: [{"name": "A", "date": "2017-01-01", "value": "103.57"}, {"name": "A", "date": "2017-01-08", ...
Neha Uniyal's user avatar
0 votes
2 answers
887 views

*ngFor: last index of the loop is null [duplicate]

This is my code in a minimal form: <div> {{ 'This is all comments Array =>'}}<br> {{selectedPost.comments}} <div *ngIf="!commentsLoading" *ngFor="#comment of ...
Siamak Motlagh's user avatar
0 votes
1 answer
305 views

Angular2 multiple bindings error [duplicate]

I have my original working code from angular1 as following: <div align="center" ng-show="showWords" > <div ng-repeat="word in whichArray | limitTo:limitToMain" ng-if="$index % 2 == 0" ...
Thinker's user avatar
  • 5,306

15 30 50 per page