1

I have installed jquery and jquery types and also tested the inclusion of jquery, by simply implementing a jquerys click function. The problem is that i am unable to call datepicker function. Here is the plunker link: http://plnkr.co/edit/3meCZf3Myg4VGzKv5x3u?p=preview This is how i have called datepicker in my component,

ngOnInit() { 
        $(function() {
            (<any>$( ".datepicker" )).datepicker();
        });
        $(".datepicker" ).change(()=>{
            let startDate =  $( "#startdate" ).val();
            let endDate =  $( "#enddate" ).val();        
            this.singleFilmEventFormService.formGroup.patchValue({
                startDate: startDate,
                endDate: endDate            
            });
        });           
    }

The angular is complaining that TypeError: $(...).datepicker is not a function

3
  • did you install jquery and @types/jquery? Commented Jun 8, 2017 at 16:05
  • yes. I tried to call jquerys click button click function, it is working. Commented Jun 8, 2017 at 16:07
  • here is the code in plunker, plnkr.co/edit/3meCZf3Myg4VGzKv5x3u?p=preview Commented Jun 8, 2017 at 17:50

1 Answer 1

1

In the top of your component file, with your import statements, try adding the following line.

declare var $: any;

Should set the $ as a variable/function/class.

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

1 Comment

Is it public on Github? Or can we get a plunkr, or gist?

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.