Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

read or write file to filesystem with angular

I will read/write a file with angular from/to my hdd. I normaly use node module "fs". Whats the best practice to combine this module with angular to use it in node webkit?

Thanks!

Edit: (can't use require in angular to load npm modules. any ideas?)

.service("WindowService", WindowService);

        function WindowService() {
            this.gui = require('nw.gui');
        }
like image 912
robert Avatar asked Jun 09 '26 12:06

robert


1 Answers

i wrote this example, if you had any questions as to how things are working? you may also want to check out this as well, which the former example uses to work outside of the browser.

but since the main question is regarding the error involving the require function, i will elaborate. require is a function implemented by the node runtime, it was added because there was no way initially built into js to import code from fileA to fileB. so when your in the browser you dont need to require anything, just make sure you have the file added to the html ie: <script src="my/file.js"></script>. but if you really want to do require in the browser, just use browserfy.

like image 195
Kyle Roux Avatar answered Jun 12 '26 01:06

Kyle Roux



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!