Ng2-NoUISlider displaying consistent range values

I'm facing an issue with implementing multiple sliders on a single page where each slider should have different range values. Here is a snippet of my HTML:

<div *ngFor="let property of comepleteFilters">
                <h5>{{property.propertyName}}</h5>
                <div *ngIf="setSliderValues(property); else renderCheckbox">

                  <nouislider #slider [min]="minSliderValue" [max]="maxSliderValue" [step]="stepSliderValue" [config]="conf" [tooltips]="[true, true]" (end)="onSliderChange($event)"></nouislider>

                </div>

And here is a snippet of my TypeScript file:

conf: any = {
    start: [0, 10],
    behaviour: 'drag'
  };

.. ..

  setSliderValues(sliderFilter: FilterList) {
    if (sliderFilter.propertyName === 'enginePower' || sliderFilter.propertyName === 'wheelBase') {
      this.minSliderValue = sliderFilter.propertyValues[0];
      this.maxSliderValue = sliderFilter.propertyValues[sliderFilter.propertyValues.length - 1];
      this.stepSliderValue = 5;
      return true;
    } else {
      return false;
    }

  }

Despite setting different values for each slider, all sliders end up with the same range values as the first slider. I even manually hardcoded values for each slider to test if the issue persists, but the problem remained. I am using Angular 6.

Answer №1

The issue arises when you assign identical values to both the minimum and maximum. This creates a problem when the setSliderValues() function is triggered, as it ends up setting both values to the same number. The variable this.minSliderValue consistently retains the value from the final iteration of the *ngFor loop.

<div *ngFor="let property of comepleteFilters">
   <h5>{{property.propertyName}}</h5>
   <div *ngIf="setSliderValues(property); else renderCheckbox">
     <nouislider #slider [min]="property.propertyValues[0]" [max]="property.propertyValues[sliderFilter.propertyValues.length - 1]" [step]="stepSliderValue" [config]="conf" [tooltips]="[true, true]" (end)="onSliderChange($event)"></nouislider>
   </div>
</div>

Answer №2

That doesn't seem to be the solution. I attempted to hardcode 2 sliders to no avail:

<nouislider #slider [min]="0" [max]="730" [step]="10" [config]="conf" [tooltips]="[true, true]"></nouislider>
<nouislider #slider [min]="2300" [max]="12000" [step]="100" [config]="conf" [tooltips]="[true, true]"></nouislider>

So far, only the step function is functioning properly.

Upon further investigation, I realized the problem stems from me utilizing the same config variable. It seems to work when I employ two different configs with identical values. Am I overlooking something?

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

Why does my Angular2 custom filter pipe execute multiple times?

I created a custom pipe to filter through my own objects, which functions correctly when used with the dropdown selector. However, I have observed that the filter is being executed multiple times, as seen in the console logs. The setup includes a dropdown ...

Modifying the values of various data types within a function

Is there a more refined approach to enhancing updateWidget() in order to address the warning in the else scenario? type Widget = { name: string; quantity: number; properties: Record<string,any> } const widget: Widget = { name: " ...

Guide on deploying a Node.js and Angular application on Google Cloud Platform

I currently have a setup where both my nodejs backend and angular frontend app are located in the same directory. The angular app generates build files in a static folder, and the nodejs backend serves the HTML file using the following code snippet: //Exp ...

Ways in which this data can be best retrieved

Hey there, I'm currently in the process of building an Ionic2 app with Firebase integration. Within my codebase, there's a provider known as Students-services where I've written a function to navigate through a node, retrieve values, and dis ...

Tips for generating a subject in rx.js while utilizing 2 parameters

Within my Angular2 application, I am utilizing a communication service to handle interactions between components. When calling the method: this.notification.create('test'); The service structure is as follows: export class NotificationServic ...

The input elements are failing to show up in the form as variables

When developing my Angular chat application, I faced an issue where a new message component was created every time a message was received. Here is the code snippet I used: feedComponent.html <app-message *ngFor="let message of chatMessages" [ChatMessa ...

Linking enumeration value to an Angular material table

Is it possible to associate enum values with an Angular Material table? For instance, I have defined an enum: export enum EnumName { val1 = 1, val2 = 2, val3 = 3 } and I want the Angular Material table to display it like this: Id EnumNameColumn ...

Camera Capacitor designed to eliminate popup notifications

I am utilizing Angular along with the camera plugin in Capacitor to locally save images on both desktop and tablets. I aim to utilize the CameraSource to directly access the camera or open the gallery for files without displaying a prompt. This is how my ...

Issue with PrimeNG Carousel width on mobile devices

Currently, I am in the process of developing a system interface with Angular and PrimeNG specifically for mobile devices. The main requirement is to have a carousel to display a set of cards. After evaluating different options, I decided to utilize the ngP ...

Is there a way to insert a Highchart Image into a spreadsheet in Excel?

Struggling to insert a Highchart's chart image into an Excel file? The goal is to utilize the current "Export Excel" button on a website to export a static image of the Highchart displayed on the webpage directly into an excel spreadsheet. Provided be ...

Angular mobile navbar experiencing collapse issue

I am working on an Angular project that does not include Jquery. I am trying to implement a navbar using mdbootstrap, but I am encountering issues with the collapse feature not working properly. Below is the HTML content I am using: <header> < ...

A comprehensive guide on implementing form array validations in Angular 8

I am currently using the formArray feature to dynamically display data in a table, which is working perfectly. However, I am facing difficulty in applying the required field validation for this table. My goal is to validate the table so that no null entry ...

Discovering the country associated with a country code using ngx-intl-tel-input

In my application, I am trying to implement a phone number field using this StackBlitz link. However, I have observed that it is not possible to search for a country by typing the country code (e.g., +231) in the country search dropdown. When I type a coun ...

Invalid data in JSON file causing issues in Vue.js

In my vuex store, I store all the translations for my application. These translations are imported from a JSON file in the following manner: import en from '@/locales/en-US.json'; const question: Module<State, any> = { namespaced: true, ...

The issue arises as ContentChildren becomes undefined while trying to retrieve the data from the server

While I am loading data from the server and displaying it in ng-content, I am encountering an issue with making the first tab active by default. When using static content like the example below, the first tab is set as active without any problems: <app ...

Default Angular2 route component for the RC5 program

My PHP website already in place, and I started integrating Angular2 components into it. I've implemented a router script to handle loading different components based on the URL. However, upon navigating away from a component page, I encounter the fol ...

Listener of events calculates the outcome

In need of help with retrieving the current coordinates of a clicked point on Google Maps. Here is my code snippet: let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); getCoords() { google.maps.event.addListener ...

Guide on utilizing a provider's variable in another provider within Ionic 2/3

In my code, I have a boolean variable called isConnection that is used to monitor network connection status. This variable is defined in a provider named 'network' and can be set to either true or false in different functions. Now, I need to acc ...

There seems to be an issue in Angular as it is unable to retrieve /

I'm encountering an issue with my simple application where I am receiving the error message "Cannot GET /." Also, in the console, I see this error: TypeError: Cannot read property 'checked' of null at Object.SL_BBL_locer. I'm unsure ab ...

Unable to utilize Next/Link in a NextJs 13 application directory

After enabling the appDir feature in Next.js 13, I encountered an error when adding a Link component: import Link from 'next/link'; function Header() { return ( <div> <Link href="/">Home</Link> </ ...