Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 3ab002f

Browse files
devversionThomasBurleson
authored andcommitted
docs(autocomplete): common issue inside of virtual repeat (#9842)
* Developers might have an autocomplete component inside of a VirtualRepeat container and will wonder why the autocompletes dropdown items are not updating. * This is because the VirtualRepeat only updates the scope bindings (rather than re-creating the autocomplete - Recycler View) and the autocomplete previously cached the results and now displays the old ones. Closes #9815.
1 parent d455bb3 commit 3ab002f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/components/autocomplete/js/autocompleteDirective.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,37 @@ angular
3535
* There is an example below of how this should look.
3636
*
3737
* ### Notes
38+
* **Autocomplete Dropdown Items Rendering**
39+
*
3840
* The `md-autocomplete` uses the the <a ng-href="api/directive/mdVirtualRepeatContainer">VirtualRepeat</a>
3941
* directive for displaying the results inside of the dropdown.<br/>
42+
*
4043
* > When encountering issues regarding the item template please take a look at the
4144
* <a ng-href="api/directive/mdVirtualRepeatContainer">VirtualRepeatContainer</a> documentation.
4245
*
46+
* **Autocomplete inside of a Virtual Repeat**
47+
*
48+
* When using the `md-autocomplete` directive inside of a
49+
* <a ng-href="api/directive/mdVirtualRepeatContainer">VirtualRepeatContainer</a> the dropdown items might
50+
* not update properly, because caching of the results is enabled by default.
51+
*
52+
* The autocomplete will then show invalid dropdown items, because the VirtualRepeat only updates the
53+
* scope bindings, rather than re-creating the `md-autocomplete` and the previous cached results will be used.
54+
*
55+
* > To avoid such problems ensure that the autocomplete does not cache any results.
56+
*
57+
* <hljs lang="html">
58+
* <md-autocomplete
59+
* md-no-cache="true"
60+
* md-selected-item="selectedItem"
61+
* md-items="item in items"
62+
* md-search-text="searchText"
63+
* md-item-text="item.display">
64+
* <span>{{ item.display }}</span>
65+
* </md-autocomplete>
66+
* </hljs>
67+
*
68+
*
4369
*
4470
* @param {expression} md-items An expression in the format of `item in results` to iterate over
4571
* matches for your search.<br/><br/>

0 commit comments

Comments
 (0)