Skip to content

nvirth/angular-globals-question

Repository files navigation

Question: How to use libs which use globals in Angular 2+

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

How to run the demonstration app

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published