Questions tagged [angular-ng-if]

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 docs:

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

1085 questions
19
votes
3 answers

AngularJS ng-if and scopes

I am trying to understand ng-if and scopes. As I am aware, ng-if creates a new child scope. Here is my issue: View
be-codified
  • 4,164
  • 15
  • 37
  • 62
17
votes
1 answer

quick leave and enter cause multiple element in angular ng-if animation

there is a ng-if animation example in this doc:https://docs.angularjs.org/api/ng/directive/ngIf if you clicking the checkbox quickly and repeatedly,you will find more than one element will be displayed,I don't know how to avoid it.
fenyiwudian
  • 330
  • 1
  • 12
15
votes
3 answers

Is there elseIf in Angular 4

I have a number of statements First Second Third Multiple conditions in above statement can be true. But what i…
Ankit Raonka
  • 4,950
  • 8
  • 27
  • 48
15
votes
5 answers

Angular 2 conditional ngFor

I'm trying to clean up my template code. I have the following:
  • {{a.firstname}}

    {{a.lastname}}

7ball
  • 1,675
  • 2
  • 20
  • 44
15
votes
8 answers

ng-if, not equal to?

I have a simple ng-reapt that displays a list of values.. On some of the outputs, i have a couple of ng-if to show/hide DIVs. HTML:

{{ details.Name }}

{{ details.DOB }}

15
votes
2 answers

How do I negate the parameter for AngularJS ng-if directive?

Quick Example: There is a routed parameter (/Home/:isLoggedIn) that equates to true or false. (/Demo/#/Home/false) and a controller property this.loggedIn = this.routeParams.loggedIn; I have a view (Home.html) that has two elements, each with an…
beauXjames
  • 7,565
  • 3
  • 42
  • 65
14
votes
2 answers

Event to fire when an angular *ngIf statement evaluates in template

If I have the following:

{{user.name}}

Is there a way I can execute code when the div above finally appears on screen?
Sammy
  • 2,087
  • 2
  • 28
  • 66
14
votes
1 answer

Angularjs: how to close ng-if in comment block?

visible
is pretty easy, but since ngIf can be used even in comments, what would be the closing
for comment block? Tried, w/o luck: .... Thanks.
Aleksandr Makov
  • 2,564
  • 2
  • 29
  • 59
14
votes
3 answers

Model does not update within ng-if

I've got a strange behavior in an angular application and I don't know if that's a bug or a known limitation: 'use strict'; var ctrl = function ($scope) { $scope.foo = false; };
stofl
  • 2,878
  • 5
  • 31
  • 48
13
votes
3 answers

AngularJS - input autofocus with ng-if not working

When I surround my input with ng-if, after hide and show the autofocus attribute does not take effect: Here is the code: