ng-class Questions
3
I want to use a variable for the value of ngClass that will be added to the class list. My use case is that I have a collection of image sprites, there is the base sprite and then an active state w...
5
Solved
Hi I have unordered list and all of them have active class. I want to toggle active class when clicked to any list item. My code is like this
<ul class="sub_modules">
<li *ngFor="let sub...
12
Solved
ALERT: This thread is for the old AngularJS!
Can we have multiple expression to add multiple ng-class ?
for eg.
<div ng-class="{class1: expressionData1, class2: expressionData2}">...
9
Solved
With AngularJS I'm using ng-class the following way:
<div class="bigIcon" data-ng-click="PickUp()"
ng-class="{first:'classA', second:'classB', third:'classC', fourth:'classC'}[call.State]"/>...
5
Solved
I try to find out the good syntax for adding classes depending on angular values.
I want to activate a class regarding 2 conditions (one on live user changes, and one on loading datas) with a OR op...
Finkelstein asked 18/6, 2014 at 14:5
5
I want to use multiple classes inside Angular [ngClass].
I have two classes, It should work accordingly as per the condition of the flag, that are already passed from the component.ts.
5
Solved
I have a very strange issue. I have to set an active class on the appropriate <li> when the $scope.selectedCat == cat.id. The list is generated with ng-repeat. If selectedCat is false, the 'B...
Constant asked 29/9, 2014 at 6:56
1
Solved
I'm trying to implement a voting system, where the active vote gets a blue background. For this I'm using 2 booleans to keep track of the score and the selected option. I tried using NgClass, but I...
3
While using ng-for loop, I want to add class to item, only if the id of the item exists in some other objects list.
I tried something like this:
<div *ngFor="let p of products" [class.Flag]="f...
Firewood asked 22/8, 2018 at 10:30
4
Solved
I have a button that changed its text to enable and disable on click.
How can I also change the button color,
For e.g. change to Green on enable and Red on disable
<button (click)="enableDisa...
Elainaelaine asked 6/8, 2018 at 21:45
3
Solved
I have an ng-repeat for a table, I want to be able to add a class when <td> is clicked, and remove the class when un-clicked. Multiple <td> can be selected at the same time. Right now A...
Reface asked 12/5, 2014 at 21:11
10
Solved
I am trying to work how to add a class with ngClick. I have uploaded up my code onto plunker Click here. Looking at the angular documentation i can't figure out the exact way it should be done. Bel...
Diploblastic asked 8/12, 2013 at 23:3
2
So I am pretty new to this.
I using Ionic 3 and trying to dynamically choose which class to use based on a condition but I cannot get ngClass to work...
Any help would be appreciated.
<div ng-...
Chaconne asked 4/5, 2018 at 1:25
1
Solved
I am attempting to add a class based off of whether or not a value is present in storage, or set to a specific value. I am attempting to use [ngClass] for this. For some reason, my function to chec...
Sain asked 19/4, 2018 at 1:28
9
Solved
I have an array of Person objects
var persons = [
{Name:'John',Eligible:true},
{Name:'Mark',Eligible:true},
{Name:'Sam',Eligible:false},
{Name:'Edward',Eligible:false},
{Name:'Michael',Eligible:tr...
5
Solved
Lets say I have some objects in an array (lets call the array "items") like { title: "Title", value: true } and I use ngFor to display them like:
<h1 *ngFor="let item of items">{{ item.title...
1
Solved
I would like to dynamically add a class based on an input parameter but only if the input is an 'approved' string.
I have a component with an input and class array from which I want to check the i...
2
Solved
So I am basically trying to set a highlight if an object is selected already. How can I compare the objects to change classes? Something like this
<[ngClass]="{{perkResult.perk === perk.perk}}...
Antho asked 1/1, 2018 at 22:36
4
Solved
I've found some code examples that explain how I can apply a class item if conditions are met.
In my .ts file I have the following:
private readNews : boolean = false;
[..]
ngOnInit() {
loca...
2
Solved
In Angular 1.x
this following code works as I want to to click and flip a card inside an ng-repeat
<div class="card" ng-repeat="let card of cards">
<div class="flipcard" ng-class="{'flipp...
3
I need to add two classes by using ng-class ,one class I am getting by a function another I need to get by an expression -
Below is code which I am using but getting some syntax error -
<div c...
1
Solved
I have a ngClass condition like this :
<div [ngClass]="{'alert alert-danger': alert.type == 0,'alert alert-success': alert.type == 1}"
If alert.type == 1, my class is alert alert-succes, but ...
2
Solved
<ul>
<li data-ng-repeat="image in images" data-ng-click="toggle = !toggle" data-ng-init="toggle=false">
<img data-ng-class="{'active' : toggle}" src="" />
</li>
</ul&g...
Compo asked 28/8, 2014 at 23:30
2
Solved
I'm trying to conditionally assign a class to a div based on the value I obtained from my back-end system.
Say there is an object 'A' which has a variable status which possibly has values st...
2
Solved
I want to use [ngClass] with a method call that returns an object like {currentWeek: true} and I want to add the var week.state that can have the value rejected.
I want that the HTML looks like th...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.