I have this code:
<script src="node_modules/nedb/browser-version/out/nedb.min.js"> </script>
<script>
var server = new Nedb({filename: 'someFile2', autoload: true});
</script>
The Nedb persistent database is created.
I just want to access the server variable in the app code, like in MyCmp.ts. How do I do this?
You need to declare Nedb inside Mycmp, then you should call the initialization code.
declare var Nedb: any;
@Component(...)
export class MyCmp {
server: any;
ngOnInit() {
this.server = new Nedb({filename: 'someFile2', autoload: true});
}
}
Now you can access this.server inside other functions inside Mycmp.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With