Material Design Angular md-autocomplete 远程 [英] Material Design Angular md-autocomplete remote

查看:28
本文介绍了Material Design Angular md-autocomplete 远程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在材料设计中自动完成(https://material.angularjs.org/#/demo/material.components.autocomplete)所有示例都展示了如何从局部变量中获取数据.通过 AJAX 调用自动完成没有帮助.

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.

推荐答案

你只需要在 md-items 中使用一个返回承诺的函数.请参阅此 plunk:http://plnkr.co/edit/KFQg53ZVfPAMum0dFctK?p=preview

You just need to use a function that returns a promise in md-items. See this plunk: http://plnkr.co/edit/KFQg53ZVfPAMum0dFctK?p=preview

注意:从 $http 返回的承诺将使用拥有数据的对象进行解析.所以你必须做这样的事情:

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
    })

这篇关于Material Design Angular md-autocomplete 远程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆