Tips for unselecting a card or button when hovering over another button or card in Angular 6

I currently have a page with multiple links such as project1, project2, and project3.

Whenever a link is clicked, it directs to the dashboard page where all projects are displayed. The selected project should be highlighted with a color change.

<a href="http://localhost:4200/#/dashboard;solution=project1;"/>
<a href="http://localhost:4200/#/dashboard;solution=project2;"/>
<a href="http://localhost:4200/#/dashboard;solution=project3;"/>

In order to achieve this highlighting effect, I am utilizing flags in my TypeScript file. However, I am facing an issue where even after hovering over other projects on the dashboard page, the originally selected project remains highlighted.

<div class="thumbnail" [ngStyle]="{'background-color':project1Flag == true?'orange':(hlsFlag != true ? '0px solid black':null)}">
  <img src="/assests/img1"/>Project1
</div>

<div class="thumbnail" [ngStyle]="{'background-color':project2Flag == true?'orange':(hlsFlag != true ? '0px solid black':null)}" (click)="mouse(e);">
  <img src="/assests/img2"/>Project2
</div>

<div class="thumbnail" [ngStyle]="{'background-color':project2Flag == true?'orange':(hlsFlag != true ? '0px solid black':null)}" (click)="mouse(e);">
  <img src="/assests/img3"/>Project3
</div>

The function "mouse()" has been implemented to reset the flag to false when hovering over other projects. Unfortunately, despite setting the flag to false, the highlighting persists. Can anyone provide assistance with resolving this issue?

Answer №1

Utilizing the click event while anticipating hover functionality is not compatible. To enable hover, switch to using (mouseenter)="mouse($event)" instead.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Bypass URL Routing for a specific route in Angular 8 and Apache

I currently have two Angular applications: the FrontEnd and Admin. Both of these are hosted on cPanel behind an Apache server. The website setup is as follows: mydomain.com/ ----> Frontend Angular Application mydomain.com/admin ----> Admin Angular ...

Bidirectional data binding in Angular 9 form controls

Implementing two-way binding in an Angular 9 form I attempted to use [(ngmodel)] in the form, however it resulted in an error. This feature has been deprecated in Angular 6 and newer versions. ...

Scroll bars on JQuery UI dialog

When using the jquery UI Dialog modal, everything appears correctly in Firefox and Chrome. However, in IE8, scroll bars suddenly appear. Is there a way to remove them? ...

Utilizing form elements within a label_tag in Ruby on Rails

I am looking to wrap my text fields and other form elements in a label tag: <label for="response">Tell me what you think: <input type="text" id="response" name="response"/></label> This allows me to apply CSS like the following: label ...

Tips for extracting data by scrolling through a webpage that initially displays only 10 items, but dynamically loads additional items as you scroll down

I am attempting to extract data from the provided webpage by collecting information contained within the title div tag. The challenge I am facing is that as I scroll down, more title tags are dynamically loaded onto the page. Initially, only a few brands a ...

Sliding through HTML content

Unfortunately, I lack expertise in advanced HTML and CSS. After some investigation, I attempted to create a "content slider" similar to the one on the Redlight Traffic website (an anti-human trafficking organization). However, my efforts have been unsucces ...

Setting up the Revolution Slider within an Angular component

Currently, I am utilizing a template that I purchased from Theme Forest as the foundation for an angular application. My goal is to transform these template parts into components. However, I am facing difficulties in getting a Revolution slider to work. ...

"Utilize JavaScript to extract data from JSON and dynamically generate a

I'm currently facing an issue with reading JSON data and populating it in my HTML table. The function to load the JSON data is not working as expected, although the data typing function is functioning properly. I have shared my complete HTML code alo ...

How can jQuery distinguish between implicit and explicit CSS height values?

When working with jQuery, I have noticed that both $('#foo').height() and $('#foo').css('height') will return a value regardless of whether a height property is explicitly set using CSS. Is there a way to determine if an eleme ...

The communication between Ajax and PHP is experiencing some technical difficulties

Hi there! I'm currently facing an issue with my Ajax call to a PHP function. My goal is to display the server time on the input field using a PHP script. Despite following an online tutorial step by step, I keep getting the actual text from the PHP fi ...

Maintain the background color of the form select drop down even after clicking away from the form

I have customized a dropdown menu. <select name="country"> <option value="Andorra">Andorra</option> <option value="Albania">Albania</option> <option value="Armenia">Armenia</option> <opt ...

Inject HTML entities, escaped for CSS, dynamically using JavaScript

My goal is to dynamically generate a list of HTMLElements with unique data-* attributes that correspond to various HTML Entities. These attributes will then be utilized by CSS to display content in pseudo elements like this: li:after { content: attr(dat ...

What criteria does Angular use to determine when the aot compiler should be utilized?

This page discusses the concept of modules in Angular and explains the two approaches to bootstrapping - dynamic and static. The configuration for these approaches is typically found in main.ts: // Using the browser platform with a compiler import { platf ...

Is it possible to manipulate an image tag's image using only CSS?

Is it possible to hide an image from the src attribute of an <img> tag and instead set a background image on the tag using CSS? One idea could be adjusting the positioning or text-indent of the actual image to move it out of view, and then applying ...

Steer clear of using grey backgrounds for anchors/links in IE 10

What is the best way to prevent the irritating grey background that appears on anchors in IE 10 when they are clicked? ...

Having trouble retrieving JSON data from the open weather API

I'm working on a small website to display the weather of a specific city using an API. However, I am facing an issue where I can't seem to display the temperature from the response. Below are snippets of my JavaScript and HTML files: var ap ...

Issue occurred when trying to load controllers during the migration process from AngularJS1 to Angular6

Currently, I am in the process of upgrading AngularJS1 components to Angular6. My strategy involves creating wrappers for all existing AngularJS1 components by extending "UpgradeComponent" and storing them under the folder "directive-wrappers". However, wh ...

Setting the thumbnail image for an HTML5 video: A step-by-step guide

Is it possible to set a thumbnail image for an HTML5 video? I would like to display an image before the video starts playing. Here is my current code: <video width="470" height="255" controls> <source src="video.mp4" type="video/mp4"> ...

Steps for updating the homepage to display a personalized welcome message to the user after logging in and redirecting using node.js and

Upon arriving at the homepage, simply click on the sign-in button. Once redirected back to the home page, you will notice a personalized greeting saying 'Welcome [user]'. Wondering how to achieve this? It's as simple as changing the text fro ...

Following the deployment of an Angular 6 Application on IIS, I am encountering a blank page without any accompanying error messages

I recently deployed an Angular 6 Application with asp.net mvc on IIS and am facing the issue of getting a blank page. The only thing showing up is the title inside the <head> in the html, but none of the contents - specifically the angular 6 compone ...