There are two controllers:

app.controller('myCtrl', function ($scope) { $.get('http://localhost:5000/Nop.Web/auction/GetJsonDataByExtId?ExtId=' + ExtId, function (data) { $scope.carsname = data[0].Name; console.log('JSON GOT IT: ' + data[0].Name); }); }); app.controller('myCtrl2', function ($scope) { $.getJSON('http://localhost:5000/Nop.Web/auction/GetJsonData', function (data) { console.log('List of objects: ' + data); }); }); 

And the markup:

 <div ng-controller="myCtrl"> <h1>Angular got it: {{carsname}}</h1> </div> 
 <div class="col col-md-12" ng-controller="myCtrl2"> <ul class="bxslider3"> </ul> </div> 

The first receives one JSON object, the second - a set of JSON objects.

It is required that the first one data[0].Name , and the second one data[0].Name list of data[i].Name

Reported as a duplicate by Grundy , aleksandr barakin , VenZell , user207618, Darth members July 16, '17 at 19:25 .

This question has been marked as a duplicate of an existing one.

  • @Grundy there is a check mark on the wrong answer ... - Pavel Mayorov
  • @PavelMayorov, yes, but I was guided by my answer :) - Grundy

1 answer 1

Outputting arrays in angular patterns is done using the ng-repeat directive. It will look like this.

Controller:

 app.controller('myCtrl2', function ($scope, $http) { $http({method: 'GET', url: 'http://localhost:5000/Nop.Web/auction/GetJsonData'}).then(function (data) { console.log('List of objects: ' + data); $scope.data = data; // Переменная data должна быть массивом! }); }); 

Template:

 <div class="col col-md-12" ng-controller="myCtrl2"> <ul class="bxslider3"> <li ng-repeat="item in data">{{item.Name}}</li> </ul> </div> 

PS angular has the means to send requests . You do not need jQuery here.

  • As a means of sending requests, it is better to use $resource , rather than $http - Sergey Rogachev
  • your example is not working - a.tarasevich
  • @ a.tarasevich What error is displayed? - Igor Golovin
  • @IgorGolovin does not come to $ scope.data - a.tarasevich
  • @ a.tarasevich use $ http or $ resource as stated above. Updated the answer - Igor Golovin