adasdasd adasdasd - 3 months ago 12
Javascript Question

Access multiple arrays from JSON using AngularJS

This is my function to fetch the array.

$scope.getclinicofuser = function()
{
var dataParameter = {
"primaryEmailId":$scope.data1.email
}

$http({
url: "/cms/api/user/getUserClinic",
method: "POST",
headers :{'Content-Type': 'application/json','Accept': 'application/json' },
data: dataParameter
}) .success(function(response) {

$scope.DomainName = response;
console.log($scope.DomainName);
});
};

});


Here is the api call response

{
"clinicNames": [2]
0: {
"clinicName": "testing"
"DomainName": "Aman.example.com"
"primaryEmailId": "example@gmail.com"
}-
1: {
"clinicName": "test-clinic"
"DomainName": "raman.example.com"
"primaryEmailId": "example@gmail.com"
}-
-
"status_code": "success"
}


My html tag

<li ng-repeat="response in DomainName">{{root.clinicNames}}</li>


Now what i want to do is to display BOTH DomainName in HTML i had a hussel with HTML ng-repeat tags but still no clues what i am doing wrong

Answer

Try

<li ng-repeat="response in DomainName.clinicNames track by $index">{{response.DomainName}}</li>