unten zu implementieren Ich habe meine eckigen und HTML-Code, zusammen mit den JSON-Daten, die ich angezeigt werden soll geschrieben. Insbesondere möchte ich {{client.label}}
tun und die Clients in einer Liste haben. Leider funktioniert das einzige, was funktioniert, wenn ich {{client}}
mache, was mir das ganze JSON-Objekt gibt, das ich nicht will. Ich bin neu in eckigen, und ich weiß, dass ich offensichtlich etwas falsch mache, aber ich bin mir nicht sicher was. Jede Hilfe wird geschätzt!Wie post korrekt mit angularjs
<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"
}
}
}
]
}
Verwenden Sie 'ng-repeat' im HTML, um über die Liste zu iterieren. –