这是我的代码。
<html>
<title>Doctor List</title>
<head>
<link rel="stylesheet" type="text/css" href="css/DoctorStay.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="js/jquery-2.2.1.min.js"></script>
<script type="text/javascript">
var d = new Date();
var weekday = new Array(7);
weekday[0]= "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";
var app=angular.module('DListApp',[]);
app.controller('DListCtrl',function($scope,$http){
$http({
method : "POST",
url : "http://localhost:81/DoctorStayServiceAngular/model/getDoctorList.php",
params:{"city":"Surat","special":"Dentist","offset":"0","gender":"Any","fees":"Any","page":"10","state":"Gujarat","country":"IN"}
}).then(function mySucces(response) {
$scope.DoctorDeatil = response.data;
}, function myError(response) {
$scope.DoctorDeatil = response.statusText;
});
$scope.booking= function(docid,addid){
//return addid;
$http({
method: 'POST',
url: "http://localhost:81/DoctorStayServiceAngular/model/getDoctorBookingDetail.php",
//params:{"doctorid":docid,"addressid":addid,"day":weekday[d.getDay()]}
params:{"doctorid":docid}
}).then(function mySucces(response) {
return response.data;
});
};
});
</script>
</head>
<body>
<div class="ListMargin">
<input type='hidden' id='current_page' />
<input type='hidden' id='show_per_page' />
<div class="row">
<div class="row" id="header"></div>
<div class="col-sm-3 AreaScroll" id="area"></div>
<div class="col-sm-8 pagination-sm" ng-app="DListApp" ng-controller="DListCtrl">
<div id="list" ng-repeat="x in DoctorDeatil">
<div class="row DocList">
<div class="container">
<div id="DocImg" class="col-sm-2">
</div>
<div id="DocDetail" class="col-sm-4">
<div class="row">
<a href="{{ x.profile_url}}">Dr. {{ x.fname}} {{ x.lname}}.</a>
</div>
<div class="row">
{{ x.lname}}
</div>
<div class="row">
{{ x.dredu}}
</div>
<div class="row">
{{ x.drspec}}
</div>
<div class="row">
<a href="{{ x.clinic_url}}"> {{ x.clinicname}}.</a>
</div>
</div>
<div id="DocAppoinment" class="col-sm-3">
{{booking(x.profileid,x.addressid)}}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- <div >
</div> -->
</body>
在$scope.booking= function(docid,addid){}
功能中当我用户$http
功能时,我的浏览器挂起了这么多。这是我的PHP代码。
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
echo json_encode($_REQUEST['doctorid']);
?>
我没有做任何新的事情,我也面临着问题。
修改
我已经改变了这样的预订功能。
$scope.booking= function(docid,addid){
i++;
console.log(i);
//console.log(addid);
return addid;
/* $http({
method: 'POST',
url: "http://localhost:81/DoctorStayServiceAngular/model/getDoctorBookingDetail.php",
//params:{"doctorid":docid,"addressid":addid,"day":weekday[d.getDay()]}
params:{"doctorid":docid}
}).then(function mySucces(response) {
return response.data;
});*/
};
在控制台中我得到了这个OP。
为什么我的预订功能正在执行2次?在控制台日志中应该只有1到10个。
答案 0 :(得分:1)
你能解释一下为什么你在 ng-repeat 中完成了这个:
<div id="DocAppoinment" class="col-sm-3">
{{booking(x.profileid,x.addressid)}}
</div>