Questions tagged [angular-ng-class]
60 questions
0
votes
1 answer
ngClass Is Loading Only One Class Out of a String of Classes
I am using ngClass (Angular 2) to load a string of classes if condition is true and other string of classes if the condition is false!
Here is the code:
0
votes
0 answers
Angular 5 [ngClass] to change language settings
The following static html
- dropdown (with style included below) works perfectly.
Now I'm trying to convert this to an Angular 5 dynamic
- using *ngFor* and ngClass .
0
votes
2 answers
add ngClass to all the divs clicked
I'm trying to add 'active' class to all the divs (options in this case) that are clicked and remove the class on a second click.
The options count can vary as it's generated by ngFor.
HTML

Akash Agrawal
- 2,219
- 1
- 17
- 38
0
votes
1 answer
how to show/hide dynamic id of div's in angular2
Here a loop of kpiName is executed and inside loops of subRegion also executed.
As a result 4 divs of class="col-xs-2" are created and inside it two div(clickable divs inside filter class) are created having dynamic Id as…

Manzer Hashmi
- 73
- 2
- 4
- 12
0
votes
1 answer
ngFor First and Last Instance of a Class Do This
I am using Angular 4+. Please note: first and last needs to be based on the class instance, not the element. So a let first = first in the ngFor will not work. I currently imported jQuery to handle this but would like to see if there is a way not…

RooksStrife
- 1,647
- 3
- 22
- 54
0
votes
1 answer
Why does my ng-class display even when false
I have an image I'm trying to shake when a user guesses the name of a fish wrong. I'm using a conditional ng-class="{'shake':error}". However, even when the answer is correct the image shakes. I don't believe that at anytime $scope.error is set to…

Taylor N
- 500
- 1
- 3
- 15
0
votes
2 answers
Toggle two classes with AngularJS / jqLite on click
I wan't to get a slideIn / slideOut animation by toggling the classes slideInRight and slideOutRight to a ul element.
I've tried it in different ways but I it only works with one className.
How can I add the class slideInRight on the first, and…

Codehan25
- 2,704
- 10
- 47
- 94
0
votes
2 answers
ng-class expression not working with parameter coming from httpresponse
I have a servlet that returns a JSON object with a parameter named "valoracion" and I want to use it for a span label to be a css class with the name of the value associated to that parameter. This I want to do it to show a .gif in a different way…

gascon95
- 115
- 1
- 10
0
votes
2 answers
Dynamically Add class to Element using AngularJS
I want to mimic something that I have done with JQuery using AngularJS.
Below is the fiddle for it.
Three things I have done here.
Find the last element of the right column.
Pickup the attribute 'data-color' from it
Assign the value of the…

nipiv
- 773
- 1
- 8
- 21
-1
votes
2 answers
How can we write two ngClass in one div?
Can we add two ng-class in one div?
If so then how to write it.
How can we write this together?
Thank you in advance.

aria08
- 21
- 3
-1
votes
2 answers
Angular : how to toggle selection between children components
So I have got a parent component with children components binded over an ngFor()such as:
Each of this categories has a title text with an ngClass like this one…

Mateo Randwolf
- 2,823
- 1
- 6
- 17
-1
votes
3 answers
The ngclass is not working as expected in angular 6
I am trying to change the value of [ngclass] field based on the values present in array but it is not working as expected.
The html code is as below:
-1
votes
1 answer
How to add a class to a specific selected li element in *ngFor
I have the following html snippets
-
yugrac
- 73
- 1
- 5
-1
votes
1 answer
Angular Built-in Directives are not working(ngClass, ngStyle, ngIf)
I am following Template syntax section for the application of built-in attribute and structural directives from here https://v4.angular.io/guide/template-syntax#ngclass
currentClasses: {};
setCurrentClasses() {
// CSS classes: added/removed…

hugolululu
- 21
- 3
-2
votes
2 answers
ngClass in Angular not applied
I am trying to use [ngClass] in Angular and seems like it is not getting applied. Surprising [ngStyle] for similar css styles are working. Waht am I doing wrong here? There is no error in the console. When I do check the dev tools the classes are…

Gary
- 2,293
- 2
- 25
- 47