{"action":"reopened","issue":{"url":"https://api.github.com/repos/valor-software/ng2-bootstrap/issues/262","repository_url":"https://api.github.com/repos/valor-software/ng2-bootstrap","labels_url":"https://api.github.com/repos/valor-software/ng2-bootstrap/issues/262/labels{/name}","comments_url":"https://api.github.com/repos/valor-software/ng2-bootstrap/issues/262/comments","events_url":"https://api.github.com/repos/valor-software/ng2-bootstrap/issues/262/events","html_url":"https://github.com/valor-software/ng2-bootstrap/issues/262","id":139589166,"number":262,"title":"Typeahead with async http REST request","user":{"login":"sschueller","id":1180107,"avatar_url":"https://avatars.githubusercontent.com/u/1180107?v=3","gravatar_id":"","url":"https://api.github.com/users/sschueller","html_url":"https://github.com/sschueller","followers_url":"https://api.github.com/users/sschueller/followers","following_url":"https://api.github.com/users/sschueller/following{/other_user}","gists_url":"https://api.github.com/users/sschueller/gists{/gist_id}","starred_url":"https://api.github.com/users/sschueller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sschueller/subscriptions","organizations_url":"https://api.github.com/users/sschueller/orgs","repos_url":"https://api.github.com/users/sschueller/repos","events_url":"https://api.github.com/users/sschueller/events{/privacy}","received_events_url":"https://api.github.com/users/sschueller/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-03-09T14:21:13Z","updated_at":"2016-09-29T09:00:18Z","closed_at":null,"body":"Can someone post me an example of how to do a typeahead with a REST service as source in Typescript? Do I need to use a promise or can I use observables? Specifically I am looking for what I need in the `getAsyncData()` function from the example here: http://valor-software.com/ng2-bootstrap/\r\n\r\nRest Response:\r\n```\r\n[{id: 1, name: 'Alabama'}, {id: 2, name: 'Alaska'}, {id: 3, name: 'Arizona'},{id: 4, name: 'Arkansas'}, {id: 5, name: 'California'}]\r\n```\r\n\r\nWhat I have (doesn't work):\r\n````\r\npublic getAsyncData(context:any):Function {\r\n        if (this._prevContext === context) {\r\n            return this._cache;\r\n        }\r\n        this._prevContext = context;\r\n        let f:Function = function (http:Http) {\r\n            let searchParams = new URLSearchParams();\r\n            searchParams.set('search', context.asyncSelected);\r\n            http.get('http://mydomain.com/search', {search: searchParams})\r\n                    .subscribe(res => {\r\n                        context.companies = res.json();\r\n                    });\r\n        };\r\n        this._cache = f(this.http);\r\n        return this._cache;\r\n}\r\n````\r\n\r\nEverything else is like in the example here: http://valor-software.com/ng2-bootstrap/\r\n\r\nAny help is greatly appreciated. Thank you."}}
{"actor":{"display_login":"sschueller"}}