1
I have a config.json file at the root of my project with some information that can be changed: folder path, etc..
I cannot create constants (angular.Constant) in the code, because as I said the values of the file can be changed in production.
But I need to read this file in module.config() and I’m not getting it, how can I do it?
I need something similar to what I do on the Server (Node.js)
var options = JSON.parse(fs.readFileSync(require('path').dirname(require.main.filename) + '/config.json'));
Configuration file:
{
"port": "3000",
"ipserver": "127.0.0.1",
"portserver": "3007"
}
How are you doing now? Could show the code that there are?
– BrTkCa
So friend, I haven’t implemented yet, I’m out of ideas, I edited the question and put a similar functionality I have on the server (Node.js), but basically I need to read/load a file. json in angular module.config.
– Geferson
I answered your question @Geferson. Javascript does not access the disk directly, you will have to search for other alternatives.
– BrTkCa
I don’t know who denied the answers, I think they are valid, just do not solve complement my problem. any additional idea?
– Geferson
Probably because you don’t understand what you have read, otherwise you would have negatively commented. If you can, post your module.config.
– BrTkCa
I’m not the one who said no, so I don’t know why. However the idea of consuming a feature at setup time is not indicated, as you are mixing two stages. Why not fire a boot service that reads the file
configuracao.json
in the method.run()
? Your application should support missing file gracefully - for example displaying an error message.– OnoSendai