Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
179
rated 0 times [  180] [ 1]  / answers: 1 / hits: 18870  / 7 Years ago, sat, december 30, 2017, 12:00:00

I have this HashMap in Frontend getting from Backend:



 var myVar = {24:{amount:2,minutes:30},32:{amount:3,minutes:30}}


Does anyone know how I can get the keys and the values in Javascript/AngularJS?
I have tried



{{myVar.24}}
{{myVar.next()}}


but nothing works.


More From » angularjs

 Answers
84

This is an object in javascript and here you use number string as a key so to access the object values use this syntax myVar[key] ; look at the example below





var myVar = {24:{amount:2,minutes:30},32:{amount:3,minutes:30}}
console.log(myVar['24']);




[#55575] Saturday, December 23, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tayla

Total Points: 681
Total Questions: 102
Total Answers: 108

Location: Marshall Islands
Member since Tue, Sep 21, 2021
3 Years ago
tayla questions
Fri, Mar 5, 21, 00:00, 3 Years ago
Wed, Oct 28, 20, 00:00, 4 Years ago
Thu, Apr 9, 20, 00:00, 4 Years ago
;