Displaying a div when an ng-repeat directive is devoid of content, incorporating filters in AngularJS

Currently, I am in need of a solution to display a specific div when my ng-repeat list is empty. The scenario involves a list containing various types of ice cream (with search filter functionality). What I aim to achieve is showing a designated div when the list does not return any items, even after conducting a search query. For this task, I am utilizing Ionic version 1 with Angular v1.54.

Despite several attempts and scouring through Stackoverflow for similar queries, I have been unable to find a suitable answer that addresses my specific issue. One such attempt involved trying out a suggestion from:

Regrettably, this approach did not yield the desired result.

Here is an excerpt of my code:

ng-repeat

<ion-item ng-repeat="item in icecreams | filter: query as filteredItems" class="item-thumbnail-left item-text-wrap repeated-item" href="#" ng-if="item.beschikbaar == 'Ja'">
      <img src="http://placehold.it/100x100">
      <h2>{{ item.name }}</h2>
      <p>{{ item.info | limitTo: 100 }}{{item.info.length > 100 ? '...' : ''}}</p>
      <h4>{{ item.type }}</h4>
      <h4>In de winkel tot: {{ item.end_date }}</h4>
  </ion-item>

Designated div when the list returns no results (even post-filtering/search)

<div class="item" ng-hide="!filteredItems.length == 0">
    <p>Er zijn geen ijssoorten gevonden!</p>
  </div>

The aforementioned implementation only functions properly when the initial list is devoid of items. Could someone provide assistance with resolving this?

Answer №1

Don't forget to verify the presence of filteredItems

<div class="item" ng-hide="filteredItems && filteredItems.length">
    <p>No ice cream flavors were found!</p>
</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

Steps for resetting data() on a route without parameters:

Having trouble restarting a route on a new editor I have a specific route /editor as well as /editor?_id=dasd448846acsca The /editor route consists of a simple form with empty inputs, while the /editor?_id=dasd448846acsca route has the same component bu ...

The type 'Pagination<UserEntity>' is lacking the following attributes from type 'UserEntity':

I have set up pagination using the library found at https://github.com/nestjsx/nestjs-typeorm-paginate. However, I am encountering an error with the code snippet below: return this.usersService.findAll({ page, limit }); Can anyone offer insight into wha ...

sending information to $modal in AngularUI

Hey there, I've been working with Angular ui $modal to create some modals lately. However, I've been running into issues when trying to pass data to the modal using resolve. Does anyone have any tips on how to solve this problem? // Manage Vi ...

Positioning Firefox absolutely within a table-cell element is possible

Interestingly, it's not Internet Explorer causing me trouble this time, but Firefox. Here is the Fiddle link for reference: http://jsfiddle.net/EwUnt/ The purpose of this table is to highlight both the row and column of the cell where the cursor is ...

Error Handling with Firebase Cloud Firestore and State Management in Vue using Vuex (firebase.firestore.QuerySnapshot)

Upon examining the code, I noticed an issue with docChanges. It seems to be a function, but when I try to use docChanges().doc.data().userId, I encounter the error message: store.js?3bf3:21 Uncaught TypeError: Cannot read property 'doc' of undefi ...

Navigate through the pages by selecting from the drop down menu, but the drop down seems to be missing on the second page

Check out this link. I'm interested in exploring each page linked to an item in the dropdown menu at the top of the website. Recently started using selenium, here's what I've been working on: Start by opening the driver Navigate to the w ...

Using Selenium with C# to find elements within a chart

I am trying to locate and interact with the stimulusFrequency circles on this chart so that I can click and drag them. <svg class="svg-graph-content graphEventHandler ng-valid" ng-model="hearingGraph" viewBox="0 0 470 355" preserveAspectRatio="none"> ...

Guide to verifying Regular Expressions for text fields in JSP with JavaScript

Need help with validating the firstname using regex. The javascript code provided generates an error if the value length is 0, however, even after entering a correct firstname format based on the regex, it still shows 'First name invalid'. I susp ...

Step-by-step guide for embedding a Big Commerce website into an iframe

Can a website be opened inside an iframe? If not, is it possible to display a message like 'page not found' or 'this website does not allow data fetching in iframes'? <!DOCTYPE html> <html> <body> <h1>Using the ...

What are the distinctions and appropriate situations for utilizing controllers versus directives?

I'm having difficulty grasping the significance of a controller. I know that it is used to reference things, but considering you can include it in a directive, are there any situations where using ng-controller for a particular section in your HTML wo ...

Tips on redirecting the treeview menu using Material-UI 4

Currently, I am utilizing Material UI 4's Treeview component. However, I am struggling to figure out how to include a parameter that allows me to redirect to other pages when the user clicks on an item. In the past, I relied on a different method. Ch ...

Discovering the function responsible for styling a DOM elementDiscovering how to identify the

I have a Prestashop 1.6 store and I've noticed that when I scroll down, my main menu becomes fixed at the top of the page. However, when I scroll back up, it reverts to its default position in the header. The issue is that the height of the menu is se ...

I've come across some strange JavaScript code while tinkering with an Express/Socket.io application

I am currently working on developing an app similar to SCADA using Brian Ford's amazing https://github.com/btford/angular-socket-io-seed as a starting point. However, I have encountered some JavaScript code that I find quite confusing. I have tried se ...

Validation in ASP.Net to ensure the correct number of days between the arrival and departure dates

One of my project requirements involves checking the validation of the number of days entered between two date selectors (From & To Dates). The constraint is that the difference should not exceed 100 days. I'm considering using ASP.NET validators for ...

Understanding app.bundle.js errors in Ionic 2

I recently updated an app from an earlier Ionic 2 Alpha version to the latest Ionic 2 Beta 10. This upgrade has caused some of my code to break, and I'm struggling to understand the errors shown in the JavaScript console. The TypeScript is all bundled ...

transforming a div to behave similarly to an iframe

I am trying to load content from my page into a div element using the following function: function loadmypage(DIV, pageURL) { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } e ...

What is the best way to create a selection input using buttons and save the chosen option in the state?

Check out this snippet showcasing 3 buttons const [role, setRole] = React.useState('') const [active, setActive] = React.useState(false) <Grid container spacing={1}> <Grid item xs={4}> <Button variant='plain&apos ...

What is the syntax for inserting a text (value) into a text input field in HTML using PHP?

I'm having trouble getting the input field to populate with "Hello" when the button is clicked. I've checked for a solution, but can't seem to find one. Any help would be appreciated. Thank you. <!DOCTYPE html> <html> <head&g ...

Animating colors with jQuery and shifting SVG shapes to create dynamic and

I am currently working on an svg animation that involves changing the color of the svg to a different color, creating a running light effect. Rather than fading the fill color of the entire svg as commonly seen in examples, I aim to achieve a dynamic trans ...

The PasswordResetView in Django using Vue.js encounters a 403 Forbidden error when attempting to post with Axios due to an

I'm currently working on building a unique Email Restore page in the frontend using Vue.js. My goal is to send email input data via Axios to /api/v1/accounts/password_reset/, essentially utilizing the original ResetPasswordView as an endpoint instead ...