0

I am performing a search operation to retrieve the data. Able to call the API and get the data back.

The result object is assigned back to $scope.model

$scope.model=results;

When I look at the page and try to change the search criteria, the input field looks like frozen. I had to refresh the page again to enter the search criteria.

Two input boxes to search. ID and name. After the even operation, neither ID nor name are editable.

This is the code

    searchApp.controller('SearchController',
function SearchController($scope, SearchData, $routeParams) {
    $scope.Search= function () {       
        $scope.model= SearchData.fetch($scope.model);    
    };
});

please help me

superboy
  • 97
  • 1
  • 2
  • 15

1 Answers1

2

I had a similar problem a few days ago. My problem was that my function was putting a string into the scope, but the rest of the code was expecting a promise. Here, you look like you probably have the opposite problem. $scope.model is probably suppose to be a string or number, but fetch probably returns a promise.

The solution may be to allow fetch to take a promise. If it gets things that are not promises, $q.when() it so that it becomes a promise. It's safe to $q.when promises.

John Tseng
  • 6,262
  • 2
  • 27
  • 35