The issue of overflow-y not functioning properly in conjunction with ng-repeat has been observed

As indicated in this resource, setting a fixed height for the div is suggested, but it seems like it's not working with the code provided below.

<div style="margin-top:0.5vh;">
      <div style="height:200px;border:1px solid red;overflow:auto;" ng-init = "home_init()">
        <ol>
        <li ng-repeat= "site in sites">
          <button ng-if="!(site.Initial===flash_site)" class="button button-block" style="background-color:#{{site.Color}};" ng-click="site_selected({{site}})">
            <b>{{site.Name}}</b>
          </button>
          <button ng-if="(site.Initial===flash_site)" class="button button-block" style="background-color:#FFFFFF;">
            <b>{{site.Name}}</b>
          </button>
        </li>
      </ol>
   </div>
</div>

I attempted to do the following,

<div style="height:200px;overflow-y:auto;">
  <div style="min-height:200px">
    <div ng-repeat="site in sites">
    </div>
  </div>
</div>

and tried a few other approaches, but I am puzzled as to why the div does not contain the elements generated by ng-repeat.

If anyone could shed light on this issue, I would greatly appreciate it.

Image

The scroll should be visible on the red border. The text "Queentown" is currently hidden underneath the parent div, below the red border. https://i.sstatic.net/CauoC.png

UPDATE

In fact, none of the solutions mentioned previously worked for me. The culprit turned out to be a scroll class that was enabled and causing the scroll to be disabled. Now, none of the solutions provided can be utilized successfully in my code.

Thank you for taking the time and effort to assist. Your support is greatly appreciated.

Answer №1

Check out this Plunker

<button ng-if="!(site.Initial===flash_site)" class="button button-block" ng-style="{'background-color': site.Color}" ng-click="site_selected(site)">

ng-click="site_selected({{site}})
-- unnecessary to use {{}} here.

style="background-color:#{{site.Color}};"
-- avoid using {{}} in this context as well.

Replace style with ng-style for dynamic color rendering.

If you prefer using color codes, remember to concatenate # with the color value.

ng-style="{'background-color': '#'+site.Color}"

Answer №2

Here is a code snippet for you to review:

<div style="height:200px;overflow-y:auto;" ng-init="init()">
  <div style="min-height:200px">  
      <ul>
   <li ng-repeat="x in records">{{x}}</li>
      </ul>
  </div>
</div>

Check out this link JSFiddle

Answer №3

<div style="height:200px;overflow-y:auto;" ng-init="init()">
  <div style="min-height:200px">  
      <ul>
           <li>Example</li>
           <li>Example</li>
            <li>Example</li>
            <li>Example</li>
             <li>Example</li>
              <li>Example</li>
                <li>Example</li>
                  <li>Example</li>
                   <li>Example</li>
           <li>Example</li>
            <li>Example</li>
            <li>Example</li>
             <li>Example</li>
              <li>Example</li>
                <li>Example</li>
                  <li>Example</li>
      </ul>
  </div>
</div>

Also I Provided An Example with Static Li Please Give It a Try

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

Center the HTML elements on the page

After struggling for some time, I can't seem to figure out how to center elements in the middle of a page without having a lengthy navigation bar at the bottom of the screen. Does anyone have any suggestions? https://codepen.io/picklemyrickle/pen/XWj ...

Unable to modify the active property of the specified object as it is read-only

Presented here is the interface: export interface ProductCommand extends ProductDetailsCommand { } This is the ProductDetailsCommand interface: export interface ProductDetailsCommand { id: string; active: boolean; archive: boolean; title: ...

Disabling the intellisense feature for locale suggestions in Monaco is recommended

Switch the keyboard language to a different one (in this case Japanese using alt + shift), and when typing in Monaco editor, an intellisense menu appears with options to remove and search. Monaco Editor Version: V0.33.0 https://i.stack.imgur.com/SIyeV.pn ...

Delete the top row from the table

After extensive searching on various websites, I am still unable to resolve my html or CSS issue. An unexpected line is appearing above the table here. Here's the code snippet that is causing trouble: <table border="0" width="840" cellspacing="0" ...

Issues arise when using ng-repeat in conjunction with ng-click

I am facing some new challenges in my spa project with angularjs. This is the HTML snippet causing issues: <a ng-repeat="friend in chat.friendlist" ng-click="loadChat('{{friend.friend_username}}')" data-toggle="modal" data-target="#chat" d ...

Saving data in a Spring MVC Angular JS application may involve storing null values in the database

angular js code <body data-ng-app="myApp" data-ng-controller="UserController as userBean"> <form method="post" action="register" name="myForm"> <div class="form-group col-lg-7" > <label for="username" class="control-label">First ...

Incorporating Anchors for Seamless Navigation in Menus

My website has various sections on the homepage and I want to add an anchor link to the navigation. This will allow users to scroll down to a specific section, like "About Us," when clicking on the appropriate nav link. I also need the anchor link to work ...

When hovered over, the submenu quickly adjusts its size within 0.1 seconds

Whenever you hover over the Galerija, a submenu pops up. However, there seems to be an issue where the right side of the submenu twitches or resizes for about 0.1 seconds initially. If anyone has any insight on this problem, I would greatly appreciate it. ...

Angular: Enhance communication with controllers and directives

Currently, I am in the process of learning Angular. One interesting feature I have been working on is a directive that displays a select element. Whenever there is a change in this select element due to the ng-change event, a specific method defined in the ...

Is it considered fashionable to utilize HTML5 data attributes in conjunction with JavaScript?

Currently, I am utilizing HTML5 data attributes to save information such as the targeted DOM element and to initialize events using jQuery's delegation method. An example of this would be: <a href="#" data-target="#target" data-action="/update"> ...

Embed a React component within another component

Recently, I've started learning React and I'm utilizing material-ui for my project. My goal is to create a customized autocomplete feature in React where selected data from the dropdown will appear as chips inside the text input field. I am curre ...

Encountering a white screen while loading StaticQuery on Gatsby website

I encountered an error that has been reported in this GitHub issue: https://github.com/gatsbyjs/gatsby/issues/25920. It seems like the Gatsby team is currently occupied and unable to provide a solution, so I'm reaching out here for help. Just to clar ...

Sticky positioning and outline effects

I have been working on creating a scrollable list with "sticky" headers. The functionality seems to be in place, but there are some visual glitches that I've encountered. The list itself is structured using a ul element styled with the Bootstrap 5 cl ...

Height CSS does not conceal side bar hyperlinks

CSS .nested-menu { .list-group-item { cursor: pointer; } .nested { list-style-type: none; } ul.submenu { height: 0; } & .expand { ul.submenu { ...

How to use jQuery to extract a JSON snippet from a lengthy string

I received an AJAX response in the form of a lengthy string, which includes HTML and JSON data. The JSON object is embedded within the string and not always at the end. My goal is to extract the JSON object from the string so that I can utilize it with th ...

Animated CSS side panel

I'm currently working on creating an animation for a side menu. The animation works perfectly when I open the menu, but the problem arises when I try to animate it back closed. Is there a property that allows the animation to play in reverse when the ...

Modify the content in the v-navigation-drawer upon clicking

I am currently working on a project with a v-navigation-drawer and two buttons. The first button is designed to open the drawer, while the second one should change the content of the drawer without closing it. I want the content to update instantly without ...

Encountering the error message ERR_CONNECTION_TIMED_OUT while using Vue CLI

Currently, I am venturing into the world of Vuex and attempting to incorporate some API requests using this state management pattern. Here is the structure I have set up: Component.Vue export default { created() { this.$store.dispatch('getDat ...

Issues arise when incorporating background images with bootstrap 3

Currently working on designing a responsive layout for an online clothing store using Bootstrap 3. One of the requirements is to use background images inline styles for product containers. However, facing difficulty styling the containers and images to ach ...

Improving Visibility in AngularJS

I am new to using Angular and encountering a simple issue. I have a button that, when clicked, should reveal a grid and some hidden filters. The filters are structured like this: <div ng-show="filtroFilial" style="visibility: hidden" class="col-md-2"&g ...