Error Cannot read property remove of undefined at BrowserDomAdapter removeClass

0 votes

What is wrong with my Angular code? I am getting:

Cannot read property 'remove' of undefined at BrowserDomAdapter.removeClass ...

HTML

<ol class="breadcrumb">
    <li *ngClass="{active: step==='step1'}" (click)="step='step1; '">Step1</li>
    <li *ngClass="{active: step==='step2'}"  (click)="step='step2'">Step2</li>
    <li *ngClass="{active: step==='step3'}" (click)="step='step3'">Step3</li>
</ol>
Sep 8, 2020 in Angular by kartik
• 37,520 points
3,540 views

1 answer to this question.

0 votes

Hello @kartik,

There are several ways to add classes conditionally depends on Angular version provides :

type one

[class.my-class]="step === 'step1'"

type two

[ngClass]="{'my-class': step === 'step1'}"

and multiple option:

[ngClass]="{'my-class': step === 'step1', 'my-class2':step === 'step2' }"

type three

[ngClass]="{1:'my-class1',2:'my-class2',3:'my-class4'}[step]"

type four

[ngClass]="(step=='step1')?'my-class1':'my-class2'"

Hope it helps!!
Thank you!!

answered Sep 8, 2020 by Niroj
• 82,880 points

Related Questions In Angular

0 votes
1 answer

Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin'

Hii kartik, Removing the node_modules and the package-lock.json ...READ MORE

answered Apr 22, 2020 in Angular by Niroj
• 82,880 points
16,265 views
0 votes
1 answer

What are the type of $watch()?

hey kartik, Before you move in to the ...READ MORE

answered Feb 3, 2020 in Angular by Niroj
• 82,880 points
937 views
0 votes
1 answer

What is the use of $eval in alert()?

Hey, kartik!! There is not much difference in ...READ MORE

answered Feb 4, 2020 in Angular by Niroj
• 82,880 points
1,270 views
0 votes
1 answer

Implementation of clone linking function and no callback function

Implementation of no callback function:   app.directive( "message", function(){ ...READ MORE

answered Feb 5, 2020 in Angular by Niroj
• 82,880 points
594 views
0 votes
1 answer

What are the vulnerability related to PHP Form?

Hii, The $_SERVER["PHP_SELF"] variable can be used by ...READ MORE

answered Feb 13, 2020 in PHP by Niroj
• 82,880 points
3,132 views
+1 vote
1 answer

How can we send message multiple time to a specific person or group in whatsapp using loop?

Hii @kartik,  This is simple task to send single ...READ MORE

answered Feb 28, 2020 in Java-Script by Niroj
• 82,880 points
18,509 views
0 votes
1 answer

What is meant by passing the variable by value and reference in PHP?

Hello, When the variable is passed as value ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
3,239 views
0 votes
1 answer

Connection with MySQL server using PHP. How can we do that?

Hey @kartik, You have to provide MySQL hostname, ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
1,268 views
0 votes
1 answer

Error:Uncaught TypeError: Cannot read property 'setState' of undefined

Hello @kartik, This is due to this.delta not being bound ...READ MORE

answered Jun 4, 2020 in Angular by Niroj
• 82,880 points
1,243 views
0 votes
1 answer

Error: Cannot read property 'setState' of undefined

Hello @kartik, This is due to this.delta not being bound ...READ MORE

answered Jul 22, 2020 in Angular by Niroj
• 82,880 points
3,343 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP