gpt4 book ai didi

javascript - 使用 angularjs 自动创建行时数据不显示

转载 作者:行者123 更新时间:2023-12-03 04:38:19 24 4
gpt4 key购买 nike

当我尝试使用 ng-repeat 在 html 中显示我的数据时,它不显示。我正在尝试动态创建行。但列表没有显示。

这是我的 Controller :

app.controller('SearchBusController',['$scope','$sessionStorage','$http','$state',function($scope,$sessionStorage,$http,$state){
var a="http://localhost:8080/business/allbusiness";
$scope.BusinessList=[];
$.ajax({
type:'GET',
url:a,

success:function(data){

$scope.BusinessList=data;
console.log(data)
},
error:function(data){
//alert("unsuccessfull");
},
dataType:"json",
contentType:"application/json",
});



}]);

这是我的 html:

<div ng-app="app" ng-controller="SearchBusController">
<table class="table1" cellspacing="0px" border="1" width="60%;" style="background:white;">
<tr ng-repeat="business in BusinessList">
<td width="13%">
<img src="images/welcome.jpg" style= "width:100%;" align="left">
</td>
<td colspan="2">
<a href="">
<p><span><h3 style="color:white;">{{business.BusinessDTO.company_name}}</h3></p></span></a>
<a href="">
<p><span><h3>{{business.BusinessDTO.address}}</h3></p></span></a>
</td>
</tr>
<table>
</div>

我在 $scope.BusinessList 中获取列表

{"businessList":[{"BusinessDTO":{"businessId":1,"company_name":"Zafin","about_company":"asdasd"}},{"BusinessDTO":{"businessId":2,"company_name":"aaa","about_company":"hgfh"}}]}

有什么帮助吗?

最佳答案

只需尝试如下更新您的列表分配。

替换以下内容

$scope.BusinessList=data;   

$scope.BusinessList=data.businessList;   

关于javascript - 使用 angularjs 自动创建行时数据不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43199009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com