错误:[$ http:baddata]错误

时间:2017-09-06 11:46:23

标签: angularjs

我是angularjs的新手,我正在努力学习它。在使用Ajax $http service的小练习应用程序时,我得到了以下错误。下面是我使用的代码。

<script type="text/javascript">

var app=angular.module("angulardata",[]);

app.controller("angulardata",["$scope","$http",function($scope,$http)
{

$http.get('employee.json').then(function(response){

$scope.employees=response;  
});

}]);


    </script>
</head>

<body ng-app="angulardata" ng-controller="angulardata">

<h2>Employee Data</h2>
<table>
<tr ng-repeat="emp in employees">
<td>{{emp.firstname}}</td>
<td>{{emp.lastname}}</td>
<td>{{emp.Age}}</td>
<td>{{emp.salary}}</td>


</tr>   
</table>

enter image description here

1 个答案:

答案 0 :(得分:2)

您的json文件无效: 试着用这个

select tblKPIData.Id
     , tblKPIData.KPI_id
     , tblKPIData.Quantity
     , tblKPIData.FinancialMonth
     , tblKPIData.FinancialYear
     , tblKPIData.ImportTimestamp 
     , tblDashboadKPI.Dashboard_Id
from (
    select tblKPIData.kpi_id,
           max(tblKPIData.ImportTimestamp) as ImportTimestamp
    from tblKPIData
    group by tblKPIData.KPI_id
)
as b
inner join tblKPIData
on tblKPIData.KPI_id = b.KPI_id 
and tblKPIData.ImportTimestamp = b.ImportTimestamp
right join tblDashboadKPI
on tblDashboadKPI.KPI_Id = tblKPIData.KPI_id
where FinancialMonth = 'nov'
and FinancialYear = 2016
and tblDashboadKPI.Dashboard_Id = 5
order by tblKPIData.Id
        ,tblKPIData.KPI_id

你可以随时检查你的json是否正确:https://jsonformatter.curiousconcept.com/