The elements within the "ng-repeat" directive are not appearing as expected

My application makes a get request using Angular's http service and then loops over the returned data to display an unordered list in the view. However, I am facing an issue where the data is available after the get request but is not being displayed on the page. It seems like a CSS styling problem, but I'm unsure of how to resolve it. I want to show the unordered list within a bootstrap panel as the body.

Here is the angular code inside the controller for setting up the data:

$http.get('/messages').success(function(data) {
         console.log("Messages are "+data);
         $scope.records = data;
     });

Below is the HTML structure:

<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
    <title>jQuery Bootstrap News plugin</title>
    <!-- Other meta tags and links -->
</head>

<body ng-app="mean" ng-controller="MainCtrl">
    <!-- Body content with container, rows, panels, etc. -->

        <div class="row">
            <div  class="col-md-2 col-md-offset-1 ">
                <form  name="messageForm" novalidate="novalidate" ng-submit="onSubmit()" id="message-box">
                    <!-- Form elements -->
                </form>
            </div>            
        </div>  

</body>

</html>

Answer №1

Ever wonder why the [ul] tag style is set to "height:0px; overflow-y:hidden"? This clever trick hides your content

Alternatively, you could relocate the ng-cloak from the div.panel-body to the div.row and eliminate it from the child td

--

Postpone the binding of bootstrapNews

$(function(){
   if ($('.panel-body[ng-cloak]').length > 0)
       return window.setTimeout(arguments.callee, 10);

   $(".demo1").bootstrapNews({...});
});

Answer №2

Instead of using 'delay' tactics, a better solution would be to create a directive that triggers a callback when ng-repeat has finished.

You can take a look at how I implemented it in my code by using a directive to emit a render finished event:

dashboard.directive('onFinishRender', function ($timeout) {
    return {
        restrict: 'A',
        link: function (scope, element, attr) {
            if (scope.$last === true) {
                $timeout(function () {
                    scope.$emit(attr.onFinishRender);
                });
            }
        }
    }
});

In the controller, you can add an event listener like this:

$scope.$on('dataLoaded', function(ngRepeatFinishedEvent) {
// your code to add bootstrapNews binding
});

Then, in the HTML section, you can call them as shown below:

<div class="add_tenant_name" ng-repeat="tenant in tenants" on-finish-render="dataLoaded">
    // more divs
</div>

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 I trigger an event in Vue.js when a selection is made in a dropdown menu?

Here is an illustration fiddle: https://jsfiddle.net/40fxcuqd/ Initially, it shows the name "Carl" If I choose Carol, Clara, etc., an event will be triggered and data will be logged to the console. However, if I click on the dropdown and select "Carl" ...

Cobalt does not reflect changes in React components when the component's state is updated

I am currently developing a small React application for Cobalt, and so far everything is running smoothly. However, I have encountered an issue with rerendering a specific portion of HTML when the component's state changes. The layout consists of a me ...

Issue with AngularJS $broadcast not functioning when initializing

In the controller, there is HTML button code that attempts to call a specific function on click: <button ng-click="vm.openpopup()" ng-if="!vm.data.length" uib-tooltip="Add Business Value Chain" class="btn btn-default `enter code h ...

avoid selecting a d3 table

I'm currently learning about creating tables in D3 and I have a question regarding when to use ".select()": For example, when constructing circles: var circles = svg.selectAll("circle") .data(dataSet) .enter() .append("circle") .att ...

Is it possible to customize the color of the placeholder and clear-icon in the ion-search bar without affecting

I am working with two ion-search bars and I need to customize the placeholder and clear icon color for just one of them. <ion-searchbar class="search-bar" placeholder="search"></ion-searchbar> My goal is to target a specific i ...

How can one append a string of text to the right of each bar? Let's find out!

.chart div { font: 10px sans-serif; background-color: steelblue; text-align: right; padding: 3px; margin: 1px; color: white; } </style> <div class="chart"></div> <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5 ...

The width values in the array are constantly shifting upon refreshing

Would it be possible to create an array called slide_widths, which will contain the widths of all the .slide elements? $( document ).ready(function() { var $slider = $('.slider ul'); var slider_width = $slider.width(); var $slides = $(&apo ...

Methods for transferring data between routes in Express without relying on query parameters or global variables

Issue at Hand :- I have set up an app.post route to receive data from an HTML page. I need to transfer the contents of req.body to an app.get route without relying on query parameters or global variables. Using query params would expose important ...

Material UI does not support the inline attribute for applying CSS properties

Trying to adjust the CSS for Material-UI When setting the width, everything works fine. However, when attempting to set display inline, an error occurs ---> "inline is not defined" Can anyone provide guidance on how to resolve this issue? Sharing my cod ...

Error: Unable to submit form with jQuery due to timeout issue - e[h] function not recognized

This question has surfaced on SO previously without any solution, maybe due to a different scenario Below is the form in question <form id="testSubmit" method="post" action="submit.php"> <!--The value of the following field will be collecte ...

The fading in process seems to be missing, leaving only the fade out effect

Here's the code snippet I am using: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> function showSignUp() { $("#re ...

Thickness of Border in Bootstrap Cards

I've been attempting to include a thicker border around the entirety of my Bootstrap 4 card. Despite specifying a thicker border, nothing seems to change. Below is a snippet of the code I'm working with: <div class="container"> <di ...

What is the best way to assign a jQuery variable to a PHP variable?

After spending some time searching and working on it, I still can't figure out the answer to this straightforward question. Here is the code I have been struggling with. <script> function calculate() { var total = (parseInt($('#stude ...

Leverage the power of Webpack to make Vue available globally

Currently, I am dealing with a situation in a legacy Rails application that has undergone some migration to integrate Webpacker and Vue. Additionally, we are utilizing a legacy script loaded through a CDN that also requires Vue. However, instead of bundlin ...

What would be the best way to structure this workflow as a JavaScript data format?

I have a complex workflow that I need to represent as a JavaScript data structure. This workflow involves a series of questions and answers where the response to one question determines the next one asked. Here is a basic example of what this workflow migh ...

What is the best way to handle constants in TypeScript?

I am facing an issue with a React component I have created: const myComponent = ({constant}: Iprops) => ( <div> {CONSTANTS[constant].property ? <showThis /> : null </div> ) The error message says 'element implicitly has ...

Finding the occurrences of elements in an array using JavaScript

While browsing Stack Overflow, I stumbled upon a question that has yet to be answered: How can I count the occurrences of elements in a specific array using JavaScript?. let array = [6, 1, 5, 1, 1, 8, 2, 4, 6, 0] // Elements in array getOccurrence(array) ...

Showing perspectives that include 'partial'/'nested' components in EXTjs 4

I am struggling to comprehend how I should define and implement the MVC model for my test application in EXTjs4. Let's take a look at the structure below. app.js Ext.application({ name: 'AM', appFolder: 'app', control ...

Customizing CSS for tables within a mat-menu in Angular Material

I am currently developing an application using Angular 7 and Angular Material cdk 6. This is my first experience working with Angular Material and I am facing a challenge in overriding the CSS styles of my columns. Despite several attempts, none of them se ...

"Fixing the position of a div on the Samsung Galaxy S8 navigation bar to

Here is the HTML code I am working with: <div class="app-bar"> <a href="#'>icon</a> <a href="#'>icon</a> <a href="#'>icon</a> <a href="#'>icon</a> </div>' ...