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

Javascript 使用angularjs自动创建行时不显示数据,javascript,angularjs,Javascript,Angularjs,当我尝试使用ng在html中显示数据时,请重复它不显示。我正在尝试动态创建行。但是列表没有显示出来 这是我的控制器: app.controller('SearchBusController',['$scope','$sessionStorage','$http','$state',function($scope,$sessionStorage,$http,$state){ var a="http://localhost:8080/business/allbusiness"; $s

当我尝试使用ng在html中显示数据时,请重复它不显示。我正在尝试动态创建行。但是列表没有显示出来

这是我的控制器:

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.$apply在$scope.BusinessList=data之后

另外,请检查您的json对象。您的json不是数组。所以你不能用ng重复。它必须是BusinessList.BusinessList


只需按如下方式更新列表作业即可

替换以下内容

$scope.BusinessList=data;   


使用$http服务来进行API调用而不是$.ajax,它将通过运行摘要周期来帮助您保持UI同步。是的,使用$http而不是$ajax,因为当您使用$ajax时,更改发生在angular的范围之外,一种丑陋的方式是调用$scope。$apply;在$scope.BusinessList=data之后的成功回调中;要手动启动apply,但建议您使用$http,但我需要$.ajax
{
      "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;