Uncaught (in promise): TypeError: this.categoryMap.get is not a function
I have problem calling functions of the Map (get, set, keys, etc) in my function. The map is returned from a firebase query.
Below is my sample code:
categoryMap = new Map<Number, String>();
//called onInit.
loadList() {
this.firestore.firestore.collection('skillType').doc('content')
.get().then(res => {
this.categoryMap = res.data().list;
});
}
sampleFunction() {
//myMap is a dummy map that I took from internet.
var myMap = new Map();
myMap.set(0, 'dummy'); //the function can be called.
console.log(myMap.get(0)); //Can get output.
console.log(this.categoryMap.get(1)); //Get the error message as title
}
This is the categoryMap
after calling loadList()
:
1: "Development & IT"
2: "Design & Creative"
3: "Accounting & Consulting"
4: "Translation & Language"
5: "Sales & Marketing"
6: "Sports & Fitness"
7: "Academic & Curricular"
8: "Culinary"
9: "Labor work"
The values are there, but why cant I call any of the function to get my data? I am so confused. Thank you for your help.
Source: Angular Questions