ng2-nouislider icon indicating copy to clipboard operation
ng2-nouislider copied to clipboard

Model isn't binding in Angular 5

Open keyanrazi opened this issue 6 years ago • 4 comments

I've been going through the demos and other issues here, but I'm not able to replicate the control in my project using Ang 5 correctly. While the control renders and functions AND the value is correctly displayed in text and on the slider onload, it's not updating my model or firing the change events.

Here's a quick example:

Initial View: image

After changing values: image

HTML:

{{ sliderValue }}

<nouislider [min]="100" [max]="350" [step]="20" 
[(ngModel)]="sliderValue" (ngModelChange)="coverageAChange($event)"></nouislider>

TS:

import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import { NouisliderComponent } from 'ng2-nouislider';

@Component({
  selector: 'app-quote',
  templateUrl: './quote.component.html',
  styleUrls: ['./quote.component.scss'],
})

export class QuoteComponent implements OnInit {


  sliderValue = 140;

  constructor() {
  }

  ngOnInit() {
  }


  coverageAChange(value) {
    console.log(value);
  };

app.module.ts:

import { NouisliderModule } from 'ng2-nouislider';

imports: [
   ....,
    NouisliderModule
  ],

.angular-cli.json:

  "styles": [
        .....,
        "../node_modules/nouislider/distribute/nouislider.min.css",
      ],

Any help would be appreciated. Thanks!

keyanrazi avatar Mar 14 '18 20:03 keyanrazi

The demo "Single Value" does not respond to Button Clicks. [(ngModel]] binding does not seem to work

brightonvino avatar Mar 15 '18 00:03 brightonvino

https://github.com/tb/ng2-nouislider/issues/157#issuecomment-362845759 Let me know if it solves your problem.

kiqq avatar Mar 15 '18 23:03 kiqq

I've changed (ngModelChange)="setValue($event) to (change)="setValue($event)" and it works for me.

tessGrant avatar Oct 25 '18 11:10 tessGrant

@tessGrant tnx worked for me too

riazXrazor avatar Apr 27 '20 09:04 riazXrazor