我正在通过使用angularjs从数据库中获取对象的json数组,但只有最后一条记录显示else没有显示。如何从数据库记录中创建json数组
var myApp=angular.module('myApp',[]);
myApp.controller('Controller',['$scope','$http',function($scope,$http) {
$scope.getAllMedicine = function(){
$http.get('http://localhost:8080/Webapp/webapi/medicine/all').success(function(data){
for(j=0; j<data.length; j++){
$scope.medicineList = [{
"medicineId" : "Id : " + data[j].medicineId,
"medicineName" : "Name : " + data[j].medicineName,
"medicinePotency" : "Potency : "+ data[j].medicinePotency,
"medicinePrice" :"Price : " +data[j].medicinePrice,
"medicineQuantity":"Quantity : " +data[j].medicineQuantity
}
]
}
});
}
}]);
谁能告诉我的错误,即时通讯制造,泥质我要感谢:)
感谢它的工作:) – Asad
@Asad - 感觉很好,以帮助你 – nikhil