Skip to content

3 party Plugins not working #2760

Closed
Closed
@RamitAnandSharma

Description

@RamitAnandSharma

Please provide us with the following information:

OS?

Windows 10

Versions.

angular-cli: 1.0.0-beta.17

Repro steps.

ng new testApp

The log given by the failure.

inline template:6:4 caused by: jQuery(...).find(...).knob is not a function
at resolvePromise (zone.js:429)
at zone.js:406
at ZoneDelegate.invoke (zone.js:203)
at Object.onInvoke (ng_zone_impl.js:43)
at ZoneDelegate.invoke (zone.js:202)
at Zone.run (zone.js:96)
at zone.js:462
at ZoneDelegate.invokeTask (zone.js:236)
at Object.onInvokeTask (ng_zone_impl.js:34)
at ZoneDelegate.invokeTask (zone.js:235)

Mention any other details that might be useful.

http://plugins.jquery.com/knob/
https://github.com/seiyria/bootstrap-slider

package.json
"dependencies": {
"@angular/common": "~2.0.0",
"@angular/compiler": "~2.0.0",
"@angular/core": "~2.0.0",
"@angular/forms": "~2.0.0",
"@angular/http": "~2.0.0",
"@angular/platform-browser": "~2.0.0",
"@angular/platform-browser-dynamic": "~2.0.0",
"@angular/router": "~3.0.0",
"bootstrap": "^3.3.7",
"bootstrap-slider": "^9.2.0",
"core-js": "^2.4.1",
"font-awesome": "^4.6.3",
"jquery": "^3.1.1",
"jquery-knob": "^1.2.11",
"moment": "^2.15.1",
"rxjs": "5.0.0-beta.12",
"tether": "^1.3.7",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23"
}

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();
}
}


> same example works in Angular2 project but not in Angular-CLI

Metadata

Metadata

Assignees

Labels

P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfulneeds: investigationRequires some digging to determine if action is needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions