简体   繁体   中英

Access to request result of elastic.js from js code

I have this code:

$scope.search = function() {
            $scope.results = ejs.Request()
                .query(ejs.TermQuery("amount", 10)).size(10).from(0)
                .doSearch();
            console.log($scope.results.v);
        };

and :

<tr id="tr" ng-repeat="record in results.hits.hits" repeat-done="reload_scroll()">
                        <td><input type="checkbox" ng-model="record._source.checked"/></td>
                        <td>{{ record._source.id }}</td>

                    </tr>

and it work properly. But I want to have access to $scope.results in js code but when I write:

$scope.search = function() {
            $scope.results = ejs.Request()
                .query(ejs.TermQuery("amount", 10)).size(10).from(0)
                .doSearch();
            console.log($scope.results.$$v);

        };

but it print undefined it console, what should I use instead $$v? Thanks.

Since it is a async call you would get the results in a callback. Something like

ejs.Request()
 .query(ejs.TermQuery("amount", 10)).size(10).from(0)
 .doSearch().then(function(data) {
         console.log(data);
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM