BobRoss BobRoss - 5 months ago 12
AngularJS Question

How to implement post correctly with angularjs

below I've posted my angular and html code, along with the json data I want to display. Specifically, I want to be able to do

{{client.label}}
and have the clients in a list. Unfortunately, the only thing that works is when I do
{{client}}
which gives me the whole json object which I don't want. I'm new to angular, and I know I'm obviously doing something wrong, but I'm not quite sure what. Any help is appreciated!

<body ng-controller="myController">
<ul>
<li ng-repeat="client in userData">
{{client.label}}

</li>
</ul>


<script>
var app = angular.module('myApp', []);

app.controller("myController", function ($scope, $http) {


$http({
url: 'myURL/blah/blah',
method: 'POST',
data:{"common": {"clientName":"6012"},"qualifier":"$ALL.$ALL.$ALL.$ALL.$ALL","pattern":"configs\\..*"} ,
headers: {'Content-Type': 'application/json'}}).success(function(data){
$scope.userData = data;
})


});





json


data:{
"parameters":[
{
"qualifier":"$ALL.$ALL.$ALL.$ALL.$ALL",
"key":"themes",
"value":{
"amairlines":{
"id":"amairlines",
"label":"American Airlines"
},
"amazonfork":{
"id":"amazonfork",
"label":"Amazon Fork"
},
"bestbuy":{
"id":"bestbuy",
"label":"Best Buy"
},
"botw":{
"id":"botw",
"label":"Bank of the West"
},
"bbva":{
"id":"bbva",
"label":"BBVA"
},
"redleaf":{
"id":"redleaf",
"label":"Red Leaf"
},
"citi":{
"id":"citi",
"label":"Citi"
},
"costco":{
"id":"costco",
"label":"Costco"
},
"firstcitizens":{
"id":"firstcitizens",
"label":"First Citizens"
},
"publix":{
"id":"publix",
"label":"Publix"
},
"homedepot":{
"id":"homedepot",
"label":"Home Depot"
},
"hsbc":{
"id":"hsbc",
"label":"HSBC"
},
"huntington":{
"id":"huntington",
"label":"Huntington"
},
"kohls":{
"id":"kohls",
"label":"Kohls"
},
"nordstrom":{
"id":"nordstrom",
"label":"Nordstrom"
},
"paypal":{
"id":"paypal",
"label":"PayPal"
},
"primax":{
"id":"primax",
"label":"Primax"
},
"td":{
"id":"td",
"label":"Toronto Dominion"
},
"usaa":{
"id":"usaa",
"label":"USAA"
}
}
}
]
}

Answer

Change the ng-repeat to this:

<li ng-repeat="client in userData.parameters[0].value">
  {{client.label}}
</li>