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

0

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes. That might be the problem. But how do I need to use $q.when()?
Thanks. I got the example from here. stackoverflow.com/questions/13033118/…

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.