Closed eduvenson closed 9 years ago
This library works only if properties files can be accesed via a url. If a requested path is not available it will print some error messages in the browser console. So first check whether your file path is valid using browser console.
Code snippet specified below shows working usage of the library.
// initialize messageResource.js
messageResource.init({
// path to directory containing config.properties
filePath : 'resource'
});
// load config.properties file
messageResource.load('config', function(){
// load file callback
// get value corresponding to a key from config.properties
var value = messageResource.get('key', 'config');
});
All files in same folder.
props.properties file: home.title = myhome home.welcome = welcomehome
JS file: function showPopup(){ messageResource.init({ //filePath: ''; filePath ignored since both js and html are in same local folder }); messageResource.load('props', function(){ var firstValue = messageResource.get('home.title', 'props'); alert(firstValue); }); }
Snapshot:
var value = messageResource.get('sample.key', 'moduleName');
the function returns the key name and not the value.