Detecting hidden child divs due to overflow: hidden in Angular6

Below is the particular issue I am aiming to address.

 <div class="row" style="overflow:hidden;">
    <app-car
      *ngFor="let car of cars; trackBy: trackByFunction"
      [car]="car"
    >
    </app-car>
 </div>

 <button> More <button>

The goal is to display the 'More' button only if there are additional cars hidden due to the overflow:hidden attribute applied to the parent container.

Answer №1

jquery;

$("div").each(function() {
  if($(this).parent().css('overflow') == 'hidden'){
    console.log("an overflow is hidden");
    }
});

Answer №2

To tackle your specific scenario in Angular 6, you can implement a combination of viewChild and ngIf.

<div class="row" style="overflow:auto;height:50px" #container>
<app-car
  *ngFor="let car of cars; trackBy: trackByFunction"
  [car]="car">
</app-car>
 </div>

<button *ngIf="container.style.overflow === 'hidden'"> More <button>

Additionally, don't forget to add the following snippet to your TypeScript file:

 @ViewChild('container') private container: ElementRef;

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

Issue encountered in Three.js related to the THREE.ObjectLoader

Help Needed with Three.ObjectLoader. I am exporting a scene in JSON Format 4.3, containing geometries, materials, and lights. The scene opens error-free in the Three.js Editor. Working on firefox with Three.js r70 master. View the generated json here: htt ...

JavaScript condensed into a single table cell rather than occupying an entire webpage

Hey there, I have a simple question that I can't seem to find the answer to anywhere. I'm working on a JavaScript function that pulls data from my database and I want it to display in one cell of a table instead of outputting to the entire page. ...

Turn off hover effect for the v-checkbox component in Vuetify 2

Is there a way to prevent the darkened circle from appearing behind a v-checkbox in Vuetify 2 when hovering over it? My v-checkbox is currently enclosed within a v-tab and a v-tooltip, although I'm not sure if that has any impact. <v-tab v-for=&quo ...

Deactivate the Autofill feature on Google Toolbar

Dealing with the Google Toolbar's autofill feature has been a constant frustration in my web development journey over the years. I have resorted to creating a timer control to monitor changes, as the developers overlooked firing change events on contr ...

Challenges Arising from the Featured Image Dimensions in WordPress

I'm currently experimenting with the featured image on this website powered by WordPress. The issue I'm facing is that the image is using a custom size instead of the size I intended. Additionally, it seems to be inheriting the characteristics of ...

Issue: The element 'app-header' is unrecognized even after including 'CUSTOM_ELEMENTS_SCHEMA'

Despite the 'app-header' component being rendered in the browser, the content in the relevant "header.component.ts" or "header.component.html" files is not appearing on the screen. https://i.sstatic.net/MfKVk.png Error: 'app-header' is ...

Dealing with the error: "Error in checking the expression as it has been altered"

I have a dialog form where users can add new projects. I want to prevent the save buttons from being enabled until all required fields are filled in correctly. I have an isValid() function that handles this validation and it appears to be working properly. ...

Switch up text using jQuery

On the first click on cta-end h1, I want to switch the text from Modification to close. Then, on the second click, from close to modification and so on. I want the text to toggle. Here is my HTML: <div id="cta-end"> <h1>Modification</ ...

CSS image replacement; won't render properly

I'm currently working on implementing a hover image swap effect for my website gallery. The CSS code I have so far is below. While the original images in my HTML file are displaying correctly, the hover functionality is not working as expected. CSS: ...

What is the best way to refresh an observable with updated information?

I am working with a singleton service that uses Observables to retrieve data from a server and display it: class HttpService { constructor() { this.$blocks = this.managerService .get() .pipe(shareReplay(1)); } } Within the templat ...

Angular is the best method for properly loading a webpage

Struggling to solve this issue. I have a webpage where I need to load another webpage, specifically a page from a different site, into a div. Essentially, it's like a news ticker that I want to showcase. The problem is that the URL is stored in a Mon ...

Replacing the resetPose function in webVR

I'm currently working on a webVR project where I previously used the resetPose function to reset the origin of the scene. However, it seems that this function is now deprecated. The purpose of using it was to bring the camera back to focusing on the c ...

Unable to successfully delete all channels in discord.js

I'm currently working on a bot designed to delete all channels within a Discord server. Here is the code I have written: const { Client, GatewayIntentBits } = require("discord.js"); const client = new Client({ intents: [ GatewayIntent ...

Rendering a Nativescript component once the page has been fully loaded

I'm currently working on integrating the WikitudeArchitectView into my TypeScript code. I've successfully registered the element in the main.ts TypeScript file: var architectView = require("nativescript-wikitudearchitectview"); registerElement ...

Conditional Matching with Javascript Regular Expressions

My strings are formatted like this: #WTK-56491650H #=> want to capture '56491650H' #M123456 #=> want to capture 'M123456' I am trying to extract everything after the # character, unless there is a dash. In that case, I onl ...

Each time my classes are initialized, their components undergo reinitialization

Apologies if the question is not well-formed, I am completely new to working with React. I have been attempting to create a dashboard but encountering issues with my states getting reinitialized. Below is the content of my app.js file. import './inde ...

Scope ng-repeat with Angular's $compile function is not functioning as expected

I am facing an issue with my directive that uses the $compile service to create a template. Despite having the users array defined in my scope, it does not populate the select options using either ng-options or ng-repeat. I am puzzled as to why this is h ...

ngIf only functions correctly when the page is reloaded

In my Angular application, I am utilizing the Oxford API which consists of two different endpoints: entries and thesaurus. My goal is to display data only if it exists using ngIf directive. While this functionality works smoothly with the entries endpoint, ...

Is there a way to fake a delayed reload when the webpage contains an audio element?

I have included an audio on my page which is causing it to load slowly. Below is the code snippet I am using: <div style="margin-left: 160px;"> <audio controls id="audio"> <source src="" type=&q ...

Tips on ensuring dispatch is finished before accessing store data. Ngrx dilemma

Is there a way to ensure that a dispatch is completed before selecting from a store? I haven't had any luck finding a solution online. How can I make sure the dispatch finishes before selecting from the store? I would appreciate any help with my code ...