Closed eliagentili closed 5 years ago
I have same problem. However it actually looks like problem with requiring Dan Grossmans's Bootstrap Datepicker. He binds it on $.fn.datepicker
but when used from angular its not present on angular.element. I am afraid that angular uses different jquery than Dan's datepicker binds on.
I'm also experiencing this problem. Any workaround?
I was able to work around this by referencing jQuery (rather than jqLite) and using the imports-loader
.
npm i jquery --save
npm i imports-loader --save-dev
Then add this to your webpack config loaders
{test: /jquery\.js$/, loader: 'expose?jQuery!expose?$'}
same problem
Now I am able to make it work . It needs script loader. Just do like below.
window.moment = require("moment");
require("script!bootstrap-daterangepicker");
require("script!angular-daterangepicker/js/angular-daterangepicker.js");
module.exports = "daterangepicker";
var app = angular.module('app',[ .... , require("./datapicker_wrapper") ] );
A module wrapper is optional. I'd like to put dependancies together. Also loading momentjs is another problem for webpack due to the locale. I use this.
I solved it by forcefully placing daterangepicker into the window object.
import * as daterangepicker from 'bootstrap-daterangepicker';
(<any>window).daterangepicker = daterangepicker
new webpack.ProvidePlugin({
$: 'jquery'
...
I am finding this issue when unit test of Angular is running. The plugin works very nice with distribution built but only causing error when unit tests are running. I am using Grunt, jasmin, karma based unit test. Angular version is 1.2.28. Can anyone help? Thanks!
I'm using wepback for importing the library and always get this error: el.daterangepicker is not a function