Angularjs 如何在此数据格式上使用ng repeat?
如何在以下数据格式中使用Angularjs 如何在此数据格式上使用ng repeat?,angularjs,angularjs-ng-repeat,Angularjs,Angularjs Ng Repeat,如何在以下数据格式中使用ng repeat: 控制器: var phonecatApp = angular.module('phonecatApp', []); phonecatApp.controller('PhoneListCtrl', ['$scope', '$http', function($scope, $http) { $http.get('https://blablabla').success(function(data) { $scope.PartnerResult
ng repeat
:
控制器:
var phonecatApp = angular.module('phonecatApp', []);
phonecatApp.controller('PhoneListCtrl', ['$scope', '$http', function($scope, $http) {
$http.get('https://blablabla').success(function(data) {
$scope.PartnerResultsBO = data;
console.log(data);
});
$scope.orderProp = 'age';
}]);
<ul class="phones">
<li ng-repeat="listing in listings.listings | filter:query | orderBy:orderProp">
<p>{{listing.makeName}}</p>
<p>{{listing.modelName}}</p>
</li>
</ul>
数据:
HTML:
var phonecatApp = angular.module('phonecatApp', []);
phonecatApp.controller('PhoneListCtrl', ['$scope', '$http', function($scope, $http) {
$http.get('https://blablabla').success(function(data) {
$scope.PartnerResultsBO = data;
console.log(data);
});
$scope.orderProp = 'age';
}]);
<ul class="phones">
<li ng-repeat="listing in listings.listings | filter:query | orderBy:orderProp">
<p>{{listing.makeName}}</p>
<p>{{listing.modelName}}</p>
</li>
</ul>
-
{{listing.makeName}
{{listing.modelName}
只有您的变量名称不正确。请在控制器列表中添加一个变量,或者按照@Joy的建议将模板从listings.listings更改为PartnerResultsBO.PartnerResultsBO.listings。这两个都是正确的。我猜您刚才输入了错误。您的概念很清楚
phonecatApp.controller('PhoneListCtrl', ['$scope', '$http', function($scope, $http) {
$http.get('https://blablabla').success(function(data) {
$scope.PartnerResultsBO = data.PartnerResultsBO;
$scope.listings= $scope.PartnerResultsBO;
console.log(data);
});
$scope.orderProp = 'age';
}]);
只有您的变量名称不正确。请在控制器列表中添加一个变量,或者按照@Joy的建议将模板从listings.listings更改为PartnerResultsBO.PartnerResultsBO.listings。这两个都是正确的。我猜您刚才输入了错别字。您的概念很清楚
phonecatApp.controller('PhoneListCtrl', ['$scope', '$http', function($scope, $http) {
$http.get('https://blablabla').success(function(data) {
$scope.PartnerResultsBO = data.PartnerResultsBO;
$scope.listings= $scope.PartnerResultsBO;
console.log(data);
});
$scope.orderProp = 'age';
}]);
只有您的变量名称不正确。请在控制器列表中添加一个变量,或者按照@Joy的建议将模板从listings.listings更改为PartnerResultsBO.PartnerResultsBO.listings。这两个都是正确的。我猜您刚才输入了错别字。您的概念很清楚
phonecatApp.controller('PhoneListCtrl', ['$scope', '$http', function($scope, $http) {
$http.get('https://blablabla').success(function(data) {
$scope.PartnerResultsBO = data.PartnerResultsBO;
$scope.listings= $scope.PartnerResultsBO;
console.log(data);
});
$scope.orderProp = 'age';
}]);
只有您的变量名称不正确。请在控制器列表中添加一个变量,或者按照@Joy的建议将模板从listings.listings更改为PartnerResultsBO.PartnerResultsBO.listings。这两个都是正确的。我猜您刚才输入了错别字。您的概念很清楚
phonecatApp.controller('PhoneListCtrl', ['$scope', '$http', function($scope, $http) {
$http.get('https://blablabla').success(function(data) {
$scope.PartnerResultsBO = data.PartnerResultsBO;
$scope.listings= $scope.PartnerResultsBO;
console.log(data);
});
$scope.orderProp = 'age';
}]);
将
listings.listings
更改为PartnerResultsBO.PartnerResultsBO.listings
或者从数据中获取列表并将其分配给范围变量列表
$scope.listings = data.PartnerResultsBO.listings;
并保持html原样。将
listings.listings
更改为PartnerResultsBO.PartnerResultsBO.listings
或者从数据中获取列表并将其分配给范围变量列表
$scope.listings = data.PartnerResultsBO.listings;
并保持html原样。将
listings.listings
更改为PartnerResultsBO.PartnerResultsBO.listings
或者从数据中获取列表并将其分配给范围变量列表
$scope.listings = data.PartnerResultsBO.listings;
并保持html原样。将
listings.listings
更改为PartnerResultsBO.PartnerResultsBO.listings
或者从数据中获取列表并将其分配给范围变量列表
$scope.listings = data.PartnerResultsBO.listings;
并保持html的原样。
listings.listings
?不是PartnerResultsBO.PartnerResultsBO.listings
?listings.listings
?不是PartnerResultsBO.PartnerResultsBO.listings
?listings.listings
?不是PartnerResultsBO.PartnerResultsBO.listings
?listings.listings
?不是PartnerResultsBO.PartnerResultsBO.listings
?