Answers for "class in angular"

6

angular ngclass

content_copy
      
      <some-element [ngClass]="'first second'">...</some-element>

<some-element [ngClass]="['first', 'second']">...</some-element>

<some-element [ngClass]="{'first': true, 'second': true, 'third': false}">...</some-element>

<some-element [ngClass]="stringExp|arrayExp|objExp">...</some-element>

<some-element [ngClass]="{'class1 class2 class3' : true}">...</some-element>
Posted by: Guest on March-14-2020
1

create class angular

// to create a model class, we first need to create a new file
//f.e person.ts

export class Person {
 constructor(
  public name: string,
   public lastName: string,
   public age:number
  
  ) {}
}

//now that we have the model class we can create arrays that contain Person class elements

.
.
public people: Person[];
constructor(){
 this.people = [
   new Person ('Carla','Smith', 20 ),
    new Person ('Carlos','Smith', 25 ),
    new Person ('Andrea','Johnson', 23 ),
   
   ];
}
Posted by: Guest on October-12-2020
0

ng class in angular

[ngClass]="{'text-success':person.country === 'UK'}"
Posted by: Guest on May-01-2021
0

ng class in angular

[class.my_class] = "step === 'step1'"
Posted by: Guest on April-27-2021
-2

ng class project

ngDoCheck()
Posted by: Guest on June-24-2020
-2

ng class in angular

<div *ngFor="let item of items">{{item}}</div>
Posted by: Guest on May-01-2021

Browse Popular Code Answers by Language