1 year ago
#322259
andyhflo
How do I use a named export from an external script in Angular?
https://stackblitz.com/edit/angular-ivy-4666q1?file=src%2Fdb%2Fdb.ts is a great demo of using Dexie in Angular, but instead of npm installing and importing, I would like to dynamically load Dexie AND Table from a CDN as described here: https://www.ngdevelop.tech/loading-external-libraries-from-cdn-in-angular-application/
After loading dynamically, my goal is to replace the following (db.ts line 1):
import Dexie, { Table } from 'dexie';
with something like this:
declare let Dexie: any;
which works great for default export "Dexie", but not sure how to declare and use the named export interface "Table" which is needed for lines 20 and 21:
todoItems!: Table<TodoItem, number>;
todoLists!: Table<TodoList, number>;
I've tried
declare let Table: any;
todoItems!: Dexie.Table<TodoItem, number>;
neither works. What should I do?
angular
interface
cdn
declare
dexie
0 Answers
Your Answer