This repo contains code to demonstrate the above question.
The demonstration uses a bootstrap 4 default navbar, which gets collapsed on mobile devices. There will be a toggler button shown (burger) to toggle the navigation menu.
Let's say I would like to be able to run this code manually:
$('.navbar-collapse').collapse('show');
This code uses the $
jquery object, and the collapse()
extension method, which is patched into $
via bootstrap.js.
There are 2 branches demonstrating my tries
- TS_import_based_solution_which_does_not_work
- This repo shows how I tried to achieve the goal the TypeScript-ish way, which does not work
- Global_based_solution
- This repo shows how I successfully achieved the goal, with a solution not so elegant.
The point is contained by these 2 commits:
Working solution: Using globals
Not working solution: Trying to use TS imports
Clone the repo, and run npm install
in its folder.
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.