Brief Explanation: I have fetched result in variable res
using **js**
.
Result of res
on console is shown below.
Requirement: I want to get the value of
res
in angular variable. I have declared
resarry = [];
When i do
this.resarry = res;
console.log(this.resaary);
Error coming - Cannot set property of 'resarray` undefined.
console.log(results); // no problem in this line
console.log(this.resarry); // giving error
export class HomePage {
resarry = [];
constructor(){
var connection = new JsStore.Instance();
var dbName = 'Demo';
connection.openDb(dbName);
connection.select({
from: Test1,
}).then(function(res) {
// results will be array of objects
console.log(res,'results');
this.resarry = results;
console.log(results); // no problem in this line
console.log(this.resarry); // giving error
}).catch(function(err) {
console.log(err, 'error');
alert(err.message);
});
}
}