Questions tagged [angular-ng-if]

'ngIf' is an Angular core directive that toggles the presence of the targeted element in the DOM. Do not use this tag for the 'ng-if' directive in the older AngularJS version.

ngIf is an Angular directive that alters the targeted element.

From the documentation:

Conditionally includes a template based on the value of an expression.

1223 questions
4
votes
2 answers

Angularjs Interpolation using double curly braces not working under ng-if

UPDATE1: developed the plunker sample that will reproduce the problem. See below. I have a strange problem in my project, where it appears in one place only. Finally, I was able to reproduce the problem using plunker…
tarekahf
  • 738
  • 1
  • 16
  • 42
4
votes
1 answer

Reusable snippets in Angular templates

We can now have else snippets, referring to an :
Condition satisfied. Condition not satisfied.
I would like to be able to refer to snippets outside of…
user663031
4
votes
1 answer

Angular: using both *ngFor and *ngIf with reference to index value in child elements

I would like to render objects from array observable in some grid-car components. In addition, I want to limit the number of grid cards to a value based on variables in my component i.e. gridCols*maxRows using *ngIf condition checking. I know that…
Michał Ziobro
  • 10,759
  • 11
  • 88
  • 143
4
votes
1 answer

Declaring a counting variable in angular2 template ngFor

Suppose I have an array of data as follows. datas : [ { nums : [121,222,124,422,521,6312,7141,812] },{ nums : [121,222,124,422,521,6312,7141,812] },{ nums : [121,222,124,422,521,6312,7141,812] } ] nums =…
Philip John
  • 5,275
  • 10
  • 43
  • 68
4
votes
1 answer

Nested *ngFor* with *ngIf

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, take a look here. Here's my code:
johnchar
  • 547
  • 10
  • 22
4
votes
1 answer

Angular 2 hide and show element using *ngIf with boolean

I want to show and hide an element by using a button that's located in another component. So I have a Dashboard with an amount of chambers in it and a header. HTML of DashboardComponent with app-header and app-chamber:
Sytham
  • 824
  • 3
  • 11
  • 25
4
votes
2 answers

ng-if shows both elements

I have two buttons that are using ng-if to determine if they should be shown or not. For a brief second, both elements are shown even though they should not be shown together ever. In isolated examples, this works fine, but in my project it has some…
Ben Winks
  • 71
  • 1
  • 4
4
votes
3 answers

ng-if causes links to show for a second then disappear. How to prevent showing

ng-if sometimes causes links on my page to show during load time, and then disappear. The link is not supposed to show at all, and I am assuming that the ng-if statement hasn't been processed yet for the second I am able to see it. Is there a way to…
ASattar
  • 82
  • 1
  • 7
4
votes
1 answer

Is there a way to prevent evaluating template inside ng-if whose condition evaluates to false?

I have an ng-repeat that acts like a switch condition that tells which template to render. I'm using ng-if inside the ng-repeat to achieve this. The problem? It's still evaluating the templates inside ng-if even if the condition evaluates to false…
supertonsky
  • 2,563
  • 6
  • 38
  • 68
4
votes
2 answers

ng-if cost 500 watchers - performance

I have an ng repeat repeating data. - Some of data.image (src) is null, and those with src=null are not to be repeated. I solved it with a simple ng-if.
Anders Pedersen
  • 2,255
  • 4
  • 25
  • 49
4
votes
2 answers

ng-if not working, ng-show works

I have an html where I must show AngularJS template only when I reach the bottom of the page (I've implemented infinite scrolling). The first page comes from the server. So I've to put an ng-if for that first page, because the user could have a…
FrancescoN
  • 2,146
  • 12
  • 34
  • 45
4
votes
3 answers

ng-repeat on non array object

I know that ng-repeat works only on array. My problem is when I don't know if the object that I get from the server, is array, or only object. I need to determine dynamically if it's array or object, and only if it's array use ng-repeat. My…
cheziHoyzer
  • 4,803
  • 12
  • 54
  • 81
4
votes
2 answers

angularjs ng-if not empty for ng-repeat

I have a list of elements I want to display only if not null and empty, and for that I placed a ng-if before a ng-repeat block:
guilhebl
  • 8,330
  • 10
  • 47
  • 66
4
votes
2 answers

Angular directive ng-if does not evaluate conditional statement

I'm new to web dev and AngularJS. I'm trying to use the directive ng-if to only display a div block if a list returned from the database is greater than 1, but it's not working. Am I misusing the directive? I've looked around and haven't found any…
Soubriquet
  • 3,100
  • 10
  • 37
  • 52
3
votes
6 answers

Angular: change style depending on *ngIf condition

I'm aware that I can do something like this:
[...]
user16241255