2

This is my code.

<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>

In $scope.booking= function(docid,addid){} function when i user $http function my browser hangs so much. This is my php code.

<?php header("Access-Control-Allow-Origin: *"); header("Content-Type: application/json; charset=UTF-8"); echo json_encode($_REQUEST['doctorid']); ?>

I am not doing anything new then also I am facing problem.

This is my console output

EDIT

I've change booking function like this.

$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;
            });*/
    };

and in console I am getting this OP.

Output

why my booking function is executing 2 time? there should be only 1 to 10 in console log.

8
  • what console says? Commented May 12, 2016 at 6:53
  • it hangs so much that i can't get chance to click on console. :( Commented May 12, 2016 at 6:59
  • make the console opened before the request starts, press F12 Commented May 12, 2016 at 7:02
  • what's your browser? Commented May 12, 2016 at 7:03
  • I've check my script in both Firefox and chrome. Commented May 12, 2016 at 7:03

1 Answer 1

1

can you explain me why you have done this inside ng-repeat:

<div id="DocAppoinment" class="col-sm-3">
{{booking(x.profileid,x.addressid)}}                                    
</div> 
Sign up to request clarification or add additional context in comments.

2 Comments

first i will get doctor list from first $http function and use loop to set those detail in div, in loop i will make another $http call to get booking detail of doctor .
it is very simple thing why you are calling another $http inside ng repeat for getting booking detail of doctors. instead of this you should do ng-repeat="x in DoctorDeatil" now DoctorDeatil would be the final scope which contain data of DocAppoinment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.