-
Notifications
You must be signed in to change notification settings - Fork 12k
3 party Plugins not working #2760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
https://github.com/aterrien/jQuery-Knob |
I have tried with both jQuery and $ |
I also have a problem adding jQuery in an angular-cli project I am working on. If I don't add the @types/jquery and declare var $: any; it works but no additional plugin seems to be working. I tried adding the types and using the solutions proposed in #2141 to add jquery but I am getting a __WEBPACK_IMPORTED_MODULE_1_jquery is not a function. From what I can see the import returns an empty object. |
Same error for me __WEBPACK_IMPORTED_MODULE_3_jquery ! |
If i add the knob.js in
then refer in my file
remove from global settings
jquery.knob.js:39 Uncaught TypeError: $ is not a function |
Ok I think I got it. If you add the jquery types there is no need to add jquery in the global script list in angular-cli.json and you can normally do an I am still trying to figure out why my jquery plugins (qtip2 in specific) does not work yet. Will get back on this if I find something |
its working for me now |
if 3 party lib does not have typings then you need to add it in angular-cli.json But the problem is how to link it whit jQuery $('a').qtip({ |
No I don't think this is correct on jquery plugins. In general, typings are there to provide types when writing typescript. It's a development tool not a production tool. So even adding the typings for qtip (or any similar jquery binding plugin) will not change whether or not the plugin will work. The thing is that qtip and pretty much every jquery plugin will (should?) start with something along the following lines:
When javascript is being evaluated in the browser, when it reaches that code block, it will call the function supplying the jQuery variable to the plugin scope as $. So it should not directly use $ from the global scope. In theory adding a vendor.ts as suggested in #2141 with the following contents:
would expose jQuery variable to the global scope thus making it available to any subsequent plugin added in the global list. However I haven't managed to get it work yet. I know I am on the right path, but I am still missing something here. |
Ok back again. I think I found out what's going on. I don't have that much experience with webpack but it seems that although adding the plugin on the global list in angular-cli.js adds it to the webpack, it does not evaluate it. Thus instead of having it there, if I just add a tl;dr;
Change angular-cli.json to read:
create a vendor.ts on the same directory as angular-cli.json that reads:
|
i have the same problem, styles and libs in angular-cli.json don't get loaded |
I have the same issue using moment. |
Closing in favor of #2141. The real bug here is actually when I think users having trouble loading any scripts/css at all were mostly in older versions of the CLI that did not have the functionality, while the readme listed it for the newer versions. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
OS?
Versions.
Repro steps.
The log given by the failure.
Mention any other details that might be useful.
http://plugins.jquery.com/knob/
https://github.com/seiyria/bootstrap-slider
I add blow in my angular-cli.json file:
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/tether/dist/js/tether.js",
"../node_modules/moment/moment.js",
"../node_modules/bootstrap/dist/js/bootstrap.js",
"../node_modules/bootstrap-slider/dist/bootstrap-slider.js",
"../node_modules/jquery-knob/dist/jquery.knob.min.js"
],
> Slider component file
import { Component, AfterViewInit, ElementRef, Inject } from '@angular/core';
declare var jQuery: any;
@component({
selector: 'app-slider',
template:
<div id="sliderUI"></div>
})
export class SliderComponent implements AfterViewInit {
elementRef: ElementRef;
slideValue: number = 0;
constructor( @Inject(ElementRef) elementRef: ElementRef) {
this.elementRef = elementRef;
}
ngAfterViewInit() {
jQuery(this.elementRef.nativeElement).find("#sliderUI").slider();
}
}
> Knob component file
import { Component, AfterViewInit, ElementRef, Inject, Input, Output, EventEmitter } from '@angular/core';
declare var jQuery: any;
@component({
selector: 'app-knob',
template:
<input type="text" id="knob" class="dial" value="25" data-width="180" min="0" max="100" data-displayinput="true" data-thickness=".05">
,})
export class KnobComponent implements AfterViewInit {
private elementRef: ElementRef;
constructor( @Inject(ElementRef) elementRef: ElementRef) {
this.elementRef = elementRef;
}
ngAfterViewInit() {
jQuery(this.elementRef.nativeElement).find("#knob").knob();
}
}
The text was updated successfully, but these errors were encountered: