Manually call $ scope. $ Apply raise error on ajax call - Error: [$ rootScope: inprog]


I tried to use Angular Material md-autocomplete, the suggestion list was retrieved from Service Host via Ajax Call. Because of Delaying response, the $scope variable was not updating the UI Properly, it updates only is there is any event occur in the specific control. For Example Focus Sent Out and again Click the Control, then it updates the UI with the new value.

My Exact issue snapshot is posted in md-items is not updating the suggesion list properly in md-autocomplete Angular Material

After a long time of google I got a theoretical solution is $scope.$apply() - reference got from Angular controller scope not updating after jQuery ajax call

But I got an error Error: [$rootScope:inprog]... Kindly assist me how to fix the error

The Complete Sample Source Code:

<!DOCTYPE html>
<link rel="stylesheet" href="">
    <script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>

<!-- Angular Material Library -->
<script src=""></script>

<div ng-app="myApp" ng-controller="myCtrl"> 

<p>Person to Select:</p>

          md-items="item in Person"
          placeholder="Which is your favorite Person?">
          <span md-highlight-text="ctrl.searchText" md-highlight-flags="^i">{{item.Name}} - {{item.City}}</span>
          No Person matching "{{searchText}}" were found.

    var app = angular.module('myApp', ['ngMaterial']);

    app.controller('myCtrl', function ($scope, $http, $q) {

        $scope.searchText = "";
        $scope.Person = [];
        $scope.selectedItem = [];
        $scope.isDisabled = false;
        $scope.noCache = false;

        $scope.selectedItemChange = function (item) {
            alert("Item Changed");
        $scope.searchTextChange = function () {

                method: "GET",
                url: "",
                params: {
                    uid: $scope.searchText
            .then(function (response) {
                $scope.$apply(function () {
                    $scope.Person =;


actually I'm using localhost for ajax call, Here I mentioned the sample Ajax URL is for your reference to get data.

Note: I need to use the $scope.$apply() within the Ajax Call without an error Error: [$rootScope:inprog]...

Kindly assist me... how to fix.

The Snapshot of Browser

$scope.$apply is automatically called by Angular when you use a $ function, so you don't have to call it yourself, the reason your UI isn't updating must be somewhere else.