在Javascript / AngularJS中获取HashMap的Key和Value(get Key and Value of HashMap in Javascript/AngularJS)
我在前端有这个HashMap从后端获取:
var myVar = {"24":{"amount":2,"minutes":30},"32":{"amount":3,"minutes":30}}有谁知道我可以如何获得JavaScript / AngularJS中的键和值? 我努力了
{{myVar.24}} {{myVar.next()}}但没有任何工作。
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.
最满意答案
这是javascript中的一个对象,在这里你使用数字字符串作为关键字,以便使用此语法访问对象值myVar [key] ; 看下面的例子
var myVar = {"24":{"amount":2,"minutes":30},"32":{"amount":3,"minutes":30}} console.log(myVar['24']);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']);
更多推荐
发布评论