简体   繁体   中英

Json data in Angularjs

I have json data in following format. I want to access data from json and print it on html table.

[region:
    [name:"",
     code:""IntradayBalance:{   currency:,Time:,Balance:    }....
    ],
    acccountcurrencyBalance:[{ currency: ,Time: ,Balance: , 
        },...],]
    [country :  
        [name:"",
         code:""
        IntradayBalance:
        {   
            currency:
            Time:
            Balance:

        }....
    ],      
    acccountcurrencyBalance:[
    {
            currency:
            Time:
            Balance:    
    },...], 
]

i Want to access data from "acccountcurrencyBalance", but im only able to print data "region name" code i am doing in my controller is as.

$http.get('data.json').success(function(data){$scope.response=data}

and my html code is

<ul ng-repeat="a in response">
    <li>{{a.region}}</li>
</ul>
<ul ng-repeat="a in response.accountcurrencyBalance">
    <li>{{a.accountcurrencyBalance.time}}</li>
</ul>

But its only able to show Region Name not the data from account currency balance. Any one can please help.

Firstly, you don't have valid json .

Example of valid json:

{"data": [{"id": 1, "name": "name1"}]}

Secondly, you have to access data.data in success function. Read $http docs:

$http.get('data.json').success(function(response){
    $scope.response=response.data; 
}

How about:

<ul ng-repeat="a in response">
    <li>{{a.region.acccountcurrencyBalance}}</li>
</ul>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM