guylabs / ion-autocomplete

A configurable Ionic directive for an autocomplete dropdown
MIT License
264 stars 88 forks source link

Cant display list in from query #16

Closed ramza1 closed 9 years ago

ramza1 commented 9 years ago

I have been trying to get this plugin to work but without help. I was able to set it up and make an api call and the form seems to work. but does not return the values as displayed in the demo. but my log shows me that something is going on.

here is my set up code

                <ion-autocomplete
                        ng-model="trade.game_id"
                        items-method="callbackMethod(query)"
                        placeholder="Find a game"
                        cancel-label="back"
                        item-value-key="title"
                        item-view-value-key = "title"
                        name="title"
                        required/>

and my callback is below

$scope.callbackMethod = function (query) { GameService.search_games({s: query}, function success(data){ console.log(data); return data }) }

My game service is

.factory('GameService', function ($resource) {
    return $resource("http://localhost:3000/api/v1/:action", {}, {
        search_games: { method:"GET", params: {action:"search_games.json"}, isArray: true }
    });
})

What am i doing wrong.

Here is my json

[ { id: 1, title: " Bloodborne", cover: "/system/games/covers/000/000/001/original/bloodborne.jpeg?1431248223", image: "http://localhost:3000/system/games/covers/000/000/001/original/bloodborne.jpeg?1431248223" }, { id: 5, title: "Mortal Kombat X ", cover: "/system/games/covers/000/000/005/original/mortal_konbatx.jpg?1431443737", image: "http://localhost:3000/system/games/covers/000/000/005/original/mortal_konbatx.jpg?1431443737" }, { id: 7, title: "Borderlands: The Handsome Collection ", cover: "/system/games/covers/000/000/007/original/BORDER.jpg?1431445199", image: "http://localhost:3000/system/games/covers/000/000/007/original/BORDER.jpg?1431445199" } ]

MystFM commented 9 years ago

I have the same problem. Looking for solution.

ramza1 commented 9 years ago

@MystFM I figured it out. I had to open the source code and used their example then i replaced the entries in the items with my results https://github.com/guylabs/ion-autocomplete/blob/master/test/e2e/ion-autocomplete.single-select.e2e.html.

guylabs commented 9 years ago

Hi,

nice that it now works. @MystFM does it also work for you now?

Regards,

Guy

MystFM commented 9 years ago

Actually, it's not. In my case, I have to change collection-repeat to ng-repeat in ion-autocomplete.js:88. Now it works well.

guylabs commented 9 years ago

Ok. What kind of ionic version do you use? And which version of the ion-autocomplete do you use?

MystFM commented 9 years ago

Ionic: Cordova CLI: 4.2.0 Ionic Version: 1.0.0-beta.14 Ionic CLI Version: 1.4.3 Ionic App Lib Version: 0.0.19 And ion-autocomplete: "name": "ion-autocomplete", "version": "0.2.1"

guylabs commented 9 years ago

Ok thanks. Could you maybe update to ionic version 1.0.0-rc.3? That's the same version as I use in the ion-autocomplete component. There were changes in the collection repeat since the beta-14 and the version upgrade should help.

Note: The plan is to upgrade to the latest 1.0.0 version in the next version of this component.