$scope.personDetails =
{
"apiversion": "0.1",
"code": 200,
"status": "OK",
"mydata": {
"myrecords": [
{
"models": [
{
"name": "Selva",
"dob": "10/10/1981"
}
],
"Address1": "ABC Street",
"Address2": "Apt 123",
"City": "NewCity1",
"State": "Georgia"
},
{
"models": [
{
"name": "Kumar",
"dob": "10/10/1982"
}
],
"Address1": "BCD Street",
"Address2": "Apt 345",
"City": "NewCity2",
"State": "Ohio",
"Country":"USA"
},
{
"models": [
{
"name": "Pranav",
"dob": "10/10/1983"
}
],
"Address1": "EFG Street",
"Address2": "Apt 678",
"City": "NewCity3",
"State": "NewYork",
"Country":"USA",
"Zipcode" :"123456"
}
]
}
}
Now i am able to statically build the UX. But my each record set's key value pair count is different. So i want to build my html dynamically as per the current record set's count.Country & Zipcode is not exist in all records so i need to build dynamically the build and populate the html output. Most of the time, my json output is dynamic. Instead of persondetails, i may get the json output of a product details instead of PersonDetails. So i can't do this if validation since i am not sure about the output field names in the json.
<div ng-show="personDetails.mydata.myrecords.length > 0" ng-repeat="recordSingle in personDetails.mydata.myrecords"> <div > <span >Address1: {{recordSingle.Address1}}</span> <span >Address2: {{recordSingle.Address2}}</span> <span>City: {{recordSingle.City}}</span> <span>State: {{recordSingle.State}}</span> <span>Country: {{recordSingle.Country}}</span> <span>Zipcode: {{recordSingle.Zipcode}}</span> </div> </div>
Hi Selva,
<div class="col-xs-12 w-xs-i" ng-switch-when='models'><h3>Name: {{value[0].name}}</h3></div>
Adapt the css to match your requirements. You can even break the normal document flow with css, and order the stuff like you want to.
Depending on your target clients, the easiest way might be using flexbox.
Regards
Sander
--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/tdXu7jGHD4Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
<span ng-repeat="(key, value) in removeSelectedAttr(recordSingle)">
$scope.removeSelectedAttr = function(items) {
var result = {};
angular.forEach(items, function(value, key) {
if (!value.hasOwnProperty("Address2") || !value.hasOwnProperty("Zipcode")) {
result[key] = value;
}
});
return result;
}
--