I am trying to create a Settings Value for my UWP-JS App on Startup.
I am following this Documentation.
Here is what I've currently got:
(function () {
"use strict"
//Initialization
var localSettings = Windows.Storage.ApplicationData.current.localSettings;
// Save value
localSettings.Values["exampleSetting"] = "example";
// Retrieve value
$('p').text(localSettings.Values["exampleSetting"]);
})();
When I start the Application it enters 'Break Mode' with the following exception in line 7 of the given code:
0x800a138f - JavaScript runtime error: Unable to set property 'exampleSetting' of undefined or null reference
What am I doing wrong?
You are missing the current
property, which is also mentioned in the example you refered to. So your call should be:
(function () {
"use strict"
//Initialization
var localSettings = Windows.Storage.ApplicationData.current.localSettings;
// Save value
localSettings.values["exampleSetting"] = "example";
// Retrieve value
$('p').text(localSettings.values["exampleSetting"]);
})();
Edit:
The properties and method names after Windows.Storage.ApplicationData
need to be start with lowercase.
User contributions licensed under CC BY-SA 3.0