We have an Angular 5 project in which we have a .json
file which we're loading in a .ts
file using XMLHttpRequest
.
The .json
file have the following content:
{
stringKey: "stringValue",
functionKey: function() {
console.log('function called!')
}
}
It throws the error: [json] value expected
If I open Chrome Devtool and set the above object as value - it works fine but not in the project
var obj = {
stringKey: "stringValue",
functionKey: function() {
console.log('function called!')
}
}
obj.functionKey();
Edit:
Is there a work around for storing functions in pure JSON?