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
3
votes
2 answers

How to trigger a directive within ngIf once ngIf finishes rendering html elements?

My problem involves the *ngif directive when once *ngif=true I want the html content to render first before my 'ModClass' directive can do its stuff. I tried to implement ngOnInit and ngViewInit but no luck since I believe ngOnInit triggers while…
3
votes
6 answers

use “OR” in *ngIf

I have a response coming from an API, and I would like to set an if condition to check if the response is 3 or 6 to set the ng-template to success else any other data gotten should be set to danger, How do I check if the data.delivery_status is 3 or…
Adeojo Emmanuel IMM
  • 2,104
  • 1
  • 19
  • 28
3
votes
1 answer
3
votes
2 answers

Using *ngIf on a directive

I have a mat-icon and a mat-badge on it containing a number. I'm looking for removing the mat-badge only if the number is <=0. I did *ngIf on the entire mat-icon, the result its obvious, it remove both mat-icon and mat-badge. Here is the…
Sergi
  • 743
  • 1
  • 9
  • 17
3
votes
1 answer

AngularDart : Property binding ngIf not used by any directive on an embedded template error while using *ngIf

I am using AngularDart where i need to show and hide component based on boolean value registerDisplay. Tried using *ngIf , but throwing an error . Below is the html. app_component.html:
Arun s
  • 869
  • 9
  • 19
3
votes
4 answers

angular ng if with async data?

In my angular navbar I have a *ngIf for rather or not login/logout button should be showing *ngIf="!authService.loggedIn() it uses a service with this loggedIn function that returns true or false loggedIn() { return…
Anders Pedersen
  • 2,255
  • 4
  • 25
  • 49
3
votes
2 answers

ngIf and formcontrol.touched is not working

I have done validation in Reactive Forms before but have never faced this issue. I have Validators.required on phone number field in sign up form. I used formcontrol.invalid and formcontrol.touched properties in template to catch the error but it…
3
votes
0 answers

Why ng-enter ng-leave action animation classes are not added in angular?

I want animation based on DOM manipulation using ngIf. There are classes(ng-enter and ng-leave) which were being applied in AngularJS Framework using ngAnimate where we can hook animation. Why they are not added to Angular. Is there any other way we…
3
votes
1 answer

Variable field name / attribute name from string dynamic variable in *ngIf

In my angular 5 app that I am working on I retrieve, from dynamodDB, a json that looks like something like this (it is retrived as an array and used with *ngFor, but for the simplisity for this question I can say it is stored like this in the…
Engam
  • 1,051
  • 8
  • 17
3
votes
1 answer

How can I submit a form if a condition is met using Angular?

I would like to submit the following form if selected equals true.
3
votes
1 answer

Angular 5: *ngIf="isValid;else other_content" VS *ngIf="isValid" . *ngIf="!isValid"

This question is about understanding why one technique is better than the other. In angular 4/5, inside a template you can achieve the same thing by doing: 1) *ngIf-else syntax
content here…
Tonio
  • 4,082
  • 4
  • 35
  • 60
3
votes
1 answer

use "or" on *ngIf to check one or another value of a variable

scenario: I'm working on a project were i have to show the diferent components of an orchestra using buttons. what i did was set a variable called "component" in my class, like this: import { Component, OnInit } from '@angular/core'; @Component({ …
Carlos Pisarello
  • 1,254
  • 5
  • 20
  • 39
3
votes
4 answers

How to calculate total days between now and a declared day in Angular?

Hello I would like to compare a day with the current date and get the total days. If the total day is greater than 50 than set "fiffty". I think the last part is easy but i cant get the solution for get the total days and compare them. is there a…
BVB1392
  • 175
  • 1
  • 1
  • 11
3
votes
2 answers

Angular - How to hide and show content with a boolean for 'this' item in a ngFor loop

I have an ngFor loop displaying several list items. Each list item contains a title. It also contains an input with the title inside it which I want hidden. When I hit an edit button, I want the input for that selected item to show, none of the…
MegaTron
  • 3,133
  • 6
  • 28
  • 45
3
votes
2 answers

Change Width of Layout in A Certain Component in Angular

Is it possible that you change the width of your layout in a selected component only? I wanted to change the
only in my login component? Only in login component and not on other components.
Joseph
  • 7,042
  • 23
  • 83
  • 181