1
 import { Component, ElementRef, Inject, AfterViewInit, Input } from '@angular/core';
declare var jQuery:any;

@Component({
  selector: 'app-slider',
  templateUrl: './slider.component.html',
  styleUrls: ['./slider.component.css']
})
export class SliderComponent implements AfterViewInit {

@Input() slideValue: number;    
elementRef: ElementRef;
visibility = 'hidden';
@Input() index: number;

constructor(@Inject(ElementRef) elementRef: ElementRef) {
  this.elementRef = elementRef;
}

updSlider() {
  jQuery(this.elementRef.nativeElement).find("#slider")
  .slider("option", "value", this.slideValue);      
}

ngAfterViewInit() { 
  jQuery(this.elementRef.nativeElement).find("#slider").slider({
    range: "min",
    orientation: "vertical",
    min: 0,
    max: 300,
    animate: true,
    step: 1,
    value: this.slideValue,
    slide: ( event, ui ) => {
      this.slideValue = ui.value;
      this.visibility = "visible";
      jQuery(this.elementRef.nativeElement).find(".ui-slider-range").css({"background": "#FFFFcc"});
    }
  });
}

     ngOnInit() {
   }

}

slider.component.ts

When i called it from my main component.

Its thowing jquery.slider is not a function.

ERROR Error: Uncaught (in promise): TypeError: jQuery(...).find(...).slider is not a function

I tried normal jquery slider also . Here also got same issue. So i tried with angular2 component from the below example.

https://plnkr.co/edit/ZoquO4A9Uk5t6Unh50gZ?p=preview

I got same issue.

Im using webpack version which is angular 4.

Any help on this can appreciate.

2
  • I don't see any errors in the plunker code you provided. Commented Jun 1, 2017 at 10:42
  • In plunker its working fine. But unbale to run in my server. Commented Jun 3, 2017 at 6:33

1 Answer 1

1

If you use Angular-CLI:

angular-cli.json:

 "scripts": [
            "../path/jquery-ui-slider.js"
     ],

Where you are using jQuery UI Slider:

 import '../../../path/jquery-ui-slider.js';

Hope it helps, let me know how it goes!

Good luck mate! ;)

Sign up to request clarification or add additional context in comments.

1 Comment

@user2215155 I am glad I was able to solve your issue! If it's the correct answer, please, mark it as such, so people can recognize it and try to solve their similar issues. Good day! ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.