tb / ng2-nouislider

Angular2 noUiSlider directive
http://tb.github.io/ng2-nouislider/
MIT License
184 stars 114 forks source link

Model isn't binding in Angular 5 #163

Open keyanrazi opened 6 years ago

keyanrazi commented 6 years ago

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!

brightonvino commented 6 years ago

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

kiqq commented 6 years ago

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

tessGrant commented 5 years ago

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

riazXrazor commented 4 years ago

@tessGrant tnx worked for me too