In material design autocomplete(https://material.angularjs.org/#/demo/material.components.autocomplete) All examples show how to get data from local variable. There is no help on doing auto complete via AJAX call.
Asked
Active
Viewed 2.2k times
16
-
It does not matter where you get the data from. Post your code – Sajeetharan Apr 08 '15 at 10:39
-
Hello sajeetharan, The example is here in source https://material.angularjs.org/#/demo/material.components.autocomplete I just need a mechanism to make it a remote call rather than looking in the local variable. – Cyril Cherian Apr 08 '15 at 10:49
-
1Just make an $http call and get the data – Sajeetharan Apr 08 '15 at 10:51
-
Yes! i am doing the $http but it is asynchronous i need to return something from the called function. The function return as per the example is an expected array. – Cyril Cherian Apr 08 '15 at 10:56
1 Answers
24
You just need to use a function that returns a promise in md-items
. See this plunk: http://plnkr.co/edit/KFQg53ZVfPAMum0dFctK?p=preview
NOTE: Returned promises from $http
will be resolved with an object that has the data. So you have to do something like this:
return $http.get(url).then(function(response){
return response.data.someOtherPathMaybe; // usually response.data
})

Alireza Mirian
- 5,862
- 3
- 29
- 48
-
3
-
-
could you implement the same on https://material.angularjs.org/1.1.1/demo/chips and provide a plunker for the same that would be really great help ! – Rizwan Patel Jan 12 '17 at 13:21