I am making a webpage using angularJS. I need to include a datepicker. Can I use jQuery UI (include jQuery too) for this or Should I use angularUI ?
Asked
Active
Viewed 64 times
0
-
I would just use AngularJS. UI Bootstrap has a datePicker which I Find suitable. – JeffryHouser Jan 04 '14 at 15:28
1 Answers
2
JQuery plugins and angular don't naturally work together very well. You can use them, but you would have to do some manual wrapping of the plugin. You're better off using angular-ui which will work out of the box.
For more info, check out the related answer "Thinking in AngularJS" if I have a jQuery background?
-
They included jquery, jqueryui.js,jqueryui.css files. so, $("#something").datepicker() will do the job, right ? so, why angularui ? – Rakesh Godhala Jan 04 '14 at 14:55
-
1Because when you go to write that code, you will realise that there isn't a sensible place to put it in an angular application. The controller should be separate from the view. Only directives should update the DOM. – Dan Jan 04 '14 at 15:06
-
You could easily write a directive with `require: 'model'` + a `link` function that adds the jQuery datepicker to the $element. Key to make it work properly is to update the AngularJS model using `ngModel.$setViewValue(newval);` when the jQuery datepicker sets a value. Something similar here: http://stackoverflow.com/a/19168292/451480 – Blaise Jan 04 '14 at 19:14