AngularJS: How to get the key of a JSON Object

后端 未结 4 1464
孤独总比滥情好
孤独总比滥情好 2021-01-31 14:45

I am unsure if this has got anything to do with AngularJS at all and if it is only JSON related.

Anyhow, let us say that we have the following JSON:

$s         


        
4条回答
  •  死守一世寂寞
    2021-01-31 14:52

    for accessing Json key-value pair from inside controller in AngularJs.

    for(var keyName in $scope.dataSets){        
         var key=keyName ;
         var value= $scope.dataSets[keyName ];
    
      alert(key)
      alert(JSON.stringify(value));
    
    }
    

提交回复
热议问题