@@ -41,8 +41,10 @@ angular
41
41
* <a ng-href="api/directive/mdVirtualRepeatContainer">VirtualRepeatContainer</a> documentation.
42
42
*
43
43
*
44
- * @param {expression } md-items An expression in the format of `item in items` to iterate over
45
- * matches for your search.
44
+ * @param {expression } md-items An expression in the format of `item in results` to iterate over
45
+ * matches for your search.<br/><br/>
46
+ * The `results` expression can be also a function, which returns the results synchronously
47
+ * or asynchronously (per Promise)
46
48
* @param {expression= } md-selected-item-change An expression to be run each time a new item is
47
49
* selected
48
50
* @param {expression= } md-search-text-change An expression to be run each time the search text
@@ -140,6 +142,34 @@ angular
140
142
*
141
143
* In this example, our code utilizes `md-item-template` and `ng-messages` to specify
142
144
* input validation for the field.
145
+ *
146
+ * ### Asynchronous Results
147
+ * The autocomplete items expression also supports promises, which will resolve with the query results.
148
+ *
149
+ * <hljs lang="js">
150
+ * function AppController($scope, $http) {
151
+ * $scope.query = function(searchText) {
152
+ * return $http
153
+ * .get(BACKEND_URL + '/items/' + searchText)
154
+ * .then(function(data) {
155
+ * // Map the response object to the data object.
156
+ * return data;
157
+ * });
158
+ * };
159
+ * }
160
+ * </hljs>
161
+ *
162
+ * <hljs lang="html">
163
+ * <md-autocomplete
164
+ * md-selected-item="selectedItem"
165
+ * md-search-text="searchText"
166
+ * md-items="item in query(searchText)">
167
+ * <md-item-template>
168
+ * <span md-highlight-text="searchText">{{item}}</span>
169
+ * </md-item-template>
170
+ * </md-autocomplete>
171
+ * </hljs>
172
+ *
143
173
*/
144
174
145
175
function MdAutocomplete ( $$mdSvgRegistry ) {
0 commit comments