Skip to content

Bootstrap with jquery in angular 2 cli webpack #1617

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

Closed
susandy opened this issue Aug 9, 2016 · 7 comments
Closed

Bootstrap with jquery in angular 2 cli webpack #1617

susandy opened this issue Aug 9, 2016 · 7 comments
Assignees

Comments

@susandy
Copy link

susandy commented Aug 9, 2016

How to include bootstrap with jquery module in angular2 cli with webpack project?

  1. Mac OSX Yosemite?
  2. angular-cli: 1.0.0-beta.11-webpack
    node: 6.2.2
    "bootstrap": "^4.0.0-alpha.2"

3.Currently, I am getting following following error
util.js:169Uncaught ReferenceError: jQuery is not defined
util.js is present under bootstrap/dist/js/umd

@hansl
Copy link
Contributor

hansl commented Aug 10, 2016

This will be handled by additional entries in the cli config.

@susandy
Copy link
Author

susandy commented Aug 10, 2016

can you elaborate which additional entries needed?

@Meligy
Copy link
Contributor

Meligy commented Aug 10, 2016

Since it's just Webpack, you can import/require jQuery followed by bootstrap.
You might get an issue with conflicting $ definition, which has a workaround here.

For the CSS, there is no finalised way of doing it today, you can check this other workaround here.

@susandy
Copy link
Author

susandy commented Aug 11, 2016

Its still not working. Getting following error

EXCEPTION: Error: Uncaught (in promise): ReferenceError: jQuery is not defined
browser_adapter.js:84EXCEPTION: Error: Uncaught (in promise): ReferenceError: jQuery is not definedBrowserDomAdapter.logError @ browser_adapter.js:84BrowserDomAdapter.logGroup @ browser_adapter.js:94ExceptionHandler.call @ exception_handler.js:65(anonymous function) @ application_ref.js:337schedulerFn @ async.js:139SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:127onError @ ng_zone.js:124onHandleError @ ng_zone_impl.js:74ZoneDelegate.handleError @ zone.js:327Zone.runGuarded @ zone.js:233_loop_1 @ zone.js:487drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426
browser_adapter.js:84STACKTRACE:BrowserDomAdapter.logError @ browser_adapter.js:84ExceptionHandler.call @ exception_handler.js:67(anonymous function) @ application_ref.js:337schedulerFn @ async.js:139SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:127onError @ ng_zone.js:124onHandleError @ ng_zone_impl.js:74ZoneDelegate.handleError @ zone.js:327Zone.runGuarded @ zone.js:233_loop_1 @ zone.js:487drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426
browser_adapter.js:84Error: Uncaught (in promise): ReferenceError: jQuery is not defined
at resolvePromise (zone.js:538)
at zone.js:515
at ZoneDelegate.invoke (zone.js:323)
at Object.onInvoke (ng_zone_impl.js:53)
at ZoneDelegate.invoke (zone.js:322)
at Zone.run (zone.js:216)
at zone.js:571
at ZoneDelegate.invokeTask (zone.js:356)
at Object.onInvokeTask (ng_zone_impl.js:44)
at ZoneDelegate.invokeTask (zone.js:355)BrowserDomAdapter.logError @ browser_adapter.js:84ExceptionHandler.call @ exception_handler.js:68(anonymous function) @ application_ref.js:337schedulerFn @ async.js:139SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:127onError @ ng_zone.js:124onHandleError @ ng_zone_impl.js:74ZoneDelegate.handleError @ zone.js:327Zone.runGuarded @ zone.js:233_loop_1 @ zone.js:487drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426
zone.js:461 Unhandled Promise rejection: jQuery is not defined ; Zone: angular ; Task: Promise.then ; Value: ReferenceError: jQuery is not defined(…)consoleError @ zone.js:461_loop_1 @ zone.js:490drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426
zone.js:463 Error: Uncaught (in promise): ReferenceError: jQuery is not defined(…)consoleError @ zone.js:463_loop_1 @ zone.js:490drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426

@susandy
Copy link
Author

susandy commented Aug 11, 2016

I am able to fix this issue by using import-loader as follows
require("imports?jQuery=jquery!./../../../node_modules/jquery-slimscroll/jquery.slimscroll.js");

@susandy susandy closed this as completed Aug 11, 2016
@filipesilva
Copy link
Contributor

Issue where this functionality is being tracked: #1717

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants