Show a visual representation once a user submits a search query

I'm a beginner in Angular and web development, and I'm trying to figure out how to display an image (check sign) when the user presses enter to submit their search. My idea was to use collapse, but I'm not sure how to do it since I don't have a search button to send the request. I apologize if this question has been asked before, but I couldn't find any clear answers.

(I am using Angular 6, HTML5, CSS3)

Thank you.

Answer №1

The Angular documentation has a specific section dedicated to handling user input, including key press events in Angular. You can learn more about it here.

To implement this functionality, you can follow a similar approach as shown below.

@Component({
  selector: 'app-key-up3',
  template: `
    <input (keyup.enter)="onEnter(box.value)">
    <div *ngIf="showTick">Place your icon here</div>
  `
})
export class KeyUpComponent_v3 {
  value = '';
  showTick = false;
  onEnter(value: string) { this.showTick = true; }
}

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

How can jQuery be used to determine if the number of checked checkboxes is a multiple of three?

Within the ul, I have li tags with checkboxes and I want to create a function that checks, when the submit button is pressed, if the number of checked checkboxes is not a multiple of 3. If it isn't, an alert should be displayed. How can I accomplish t ...

Trouble with changing background image on hover

Is there a way to change the background image when hovering over a normal image without altering the original background image? I attempted to achieve this using z-index values, but unfortunately it did not work as expected. You can view my attempt on thi ...

An issue has occurred: it seems that the property cannot be accessed because `this.child` is undefined

Is there a way to call the function "initMap" that is defined in the child component "UpdatePinComponent", from the parent component named "ApiaryComponent"? Below is a snippet of the TypeScript code from the parent component: import { AfterViewInit, Compo ...

Tips for avoiding Google Tag Manager from interfering with document.write() function

We have integrated Angular into our website, however, not all pages have been migrated to Angular yet. To handle this situation, we have implemented a hybrid approach: Each request is initially directed to Angular. Once the page is loaded, it checks if th ...

Subdirectory causing CSS failure to load

Currently, I am facing an issue with loading CSS from a subdirectory via index.php. To tackle this problem, I have defined a constant called AMIN_CSS ="http://localhost/gbl_admin/admin_css". When the file is in the same directory, the CSS loads successful ...

"Encountered an unhandled promise rejection related to the Select

I encountered an issue between my app.module.ts and my app.welcome-panel-menu-list.component.ts. Can someone help me identify the problem? app.module.ts: import { NgModule } from '@angular/core'; import { BrowserModule } from '@an ...

Create an HTML and CSS code that allows you to split paragraph text into columns within a

I am seeking a way to create dynamic paragraph column text using only the https://i.sstatic.net/ZX1AN.png Here is an example of how it could be displayed in HTML: <div> <p> Sed ut perspiciatis, unde omnis iste natus error sit voluptatem ...

What is the best approach to return an Observable value only if it is not null, otherwise invoke an HTTP service to fetch and return the

@Injectable() /*** * Profile Management Service */ export class ManageProfileService { private userDetails: any = null; public getUserDetails$: Observable<any> } I am attempting to subscribe to the GetUserDetails Observable from this se ...

Just starting out with Flexbox - what steps should I take?

In the code, there are three divs arranged in the DOM by div-00#. I am seeking to achieve the following layout using flexbox (for width >= 460px) as shown in the images below: https://i.sstatic.net/I2PFQ.png Added: 18-12-16 - https://i.sstatic.net/v ...

Use CSS to configure the mouse wheel for horizontal scrolling

Looking to create a horizontal page layout, but when I scroll with the mouse wheel the content only moves vertically. Is there a way to enable horizontal scrolling using the mouse wheel? Does CSS have a property for this? For instance, is there something ...

Surprising outcomes when hosting my website on its domain

During the development of my website, I uploaded it to Cpanel once everything was finished. It functioned perfectly fine at that time. However, after making some changes and uploading it again, the fonts and videos on the live domain appear larger than i ...

Utilizing Jquery to locate a link inside a Div and displaying it as specified in the HTML

Looking for a solution to make div elements clickable as links? The usual methods involving window.location or window.open may not be suitable if you have numerous divs with predefined targets. If you're not well-versed in Javascript, finding the righ ...

Ideal JavaScript data structure for connecting three arrays

My goal is to establish a connection between three arrays in the following manner: arr1 = ['A', 'A', 'B', 'B', 'C', 'C' 'A', 'C'] arr2 = ['a', 'aa', ' ...

Tips for ensuring that your sidebar remains contained within the boundaries of the outer div

Here is my Vue code utilizing bootstrap-vue. I am attempting to place the sidebar within the card body, but it's not displaying as intended. How can I adjust it to fit properly inside either the outer div or the b-card body? <template> <di ...

Ways to position a flexbox child at the bottom of its container

Utilizing Flexbox to arrange different content in a panel, there is an issue with the positioning of icons within each panel. The fourth icon wraps around and aligns with the first one at the top of its container, instead of lining up with the third icon a ...

Flex CSS pseudo-classes: a deep dive into styling with flex

Are pseudo-classes supported by Flex CSS selectors? I am looking to change the backgroundColor of a canvas based on mouse over and out. Currently, I am listening to MOUSE_OVER and MOUSE_OUT events and adjusting the styleName property in the handler functi ...

Running automated unit tests to ensure browser compatibility for newly written Angular framework code

Can automated JavaScript unit tests be used to assess browser compatibility? I need to conduct dom test cases on my angular 6 code in various browser environments. These unit tests must be able to run during the CI build. ...

Display a dropdown menu depending on the chosen item

In my creation of a simple dropdown list for operators, I have been contemplating whether there is a method to display dropdown items based on the selection made. For example, if I choose "Price" in the Category dropdown which requires an integer value, th ...

Is there a solution to address the issue of Mobile Safari displaying CSS in a unique

My layout consists of two columns, with data on the left and navigation on the right. While it renders correctly on Safari desktop, Safari for iPhone displays the right column at the bottom of the page underneath the data. Here is the basic code template: ...

HTML script tag failing to load

As a beginner in using scripts in HTML, I'm currently following a tutorial that suggests loading the script after the body for certain reasons. In my own code, I found that I need to place the script both in the head section and after the body. Remov ...