Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Commit 6422ca0

Browse files
committed
Merge pull request #180 from antony/patch-1
Documentation update to explain this.$parent functionality.
2 parents 8daf164 + dd7a54e commit 6422ca0

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ var app = angular.module('app', ["angucomplete-alt"]);
9595
| placeholder | Placeholder text for the search field. [example](http://ghiden.github.io/angucomplete-alt/#example1) | No | Search members |
9696
| maxlength | Maxlength attribute for the search field. [example](http://ghiden.github.io/angucomplete-alt/#example1) | No | 25 |
9797
| pause | The time to wait (in milliseconds) before searching when the user enters new characters. [example](http://ghiden.github.io/angucomplete-alt/#example1) | No | 400 |
98-
| selected-object | Either an object in your scope or callback function. If you set an object, it will be two-way-bound data as usual. If you set a callback, it gets called when selection is made. [example](http://ghiden.github.io/angucomplete-alt/#example1) | Yes | selectedObject or objectSelectedCallback |
98+
| selected-object | Either an object in your scope or callback function. If you set an object, it will be two-way-bound data as usual. If you set a callback, it gets called when selection is made. To get attributes of the input from which the assignment was made, use this.$parent.$index within your function. [example](http://ghiden.github.io/angucomplete-alt/#example1) | Yes | selectedObject or objectSelectedCallback |
9999
| remote-url | The remote URL to hit to query for results in JSON. angucomplete will automatically append the search string on the end of this, so it must be a GET request. [example](http://ghiden.github.io/angucomplete-alt/#example5) | No | http://myserver.com/api/users/find?searchstr= |
100100
| remote-url-data-field | The name of the field in the JSON object returned back that holds the Array of objects to be used for the autocomplete list. [example](http://ghiden.github.io/angucomplete-alt/#example5) | No | results |
101101
| title-field | The name of the field in the JSON objects returned back that should be used for displaying the title in the autocomplete list. Note, if you want to combine fields together, you can comma separate them here (e.g. for a first and last name combined). If you want to access nested field, use dot to connect attributes (e.g. name.first). [example](http://ghiden.github.io/angucomplete-alt/#example1) | Yes | firstName,lastName |
@@ -119,7 +119,7 @@ var app = angular.module('app', ["angucomplete-alt"]);
119119
| text-searching | Custom string to show when search is in progress. | No | "Searching for items..." |
120120
| text-no-results | Custom string to show when there is no match. | No | "Not found" |
121121
| initial-value | Initial value for component. If string, the internal model is set to the string value, if an object, the title-field attribute is used to parse the correct title for the view, and the internal model is set to the object. [example](http://ghiden.github.io/angucomplete-alt/#example9) | No | myInitialValue (object/string) |
122-
| input-changed | A callback function that is called when input field is changed. [example](http://ghiden.github.io/angucomplete-alt/#example10) | No | inputChangedFn |
122+
| input-changed | A callback function that is called when input field is changed. To get attributes of the input from which the assignment was made, use this.$parent.$index within your function. [example](http://ghiden.github.io/angucomplete-alt/#example10) | No | inputChangedFn |
123123
| auto-match | Allows for auto selecting an item if the search text matches a search results attributes exactly. [example](http://ghiden.github.io/angucomplete-alt/#example11) | No | true |
124124
| focus-in | A function or expression to be called when input field gets focused. [example](http://ghiden.github.io/angucomplete-alt/#example12) | No | focusIn() |
125125
| focus-out | A function or expression to be called when input field lose focus. [example](http://ghiden.github.io/angucomplete-alt/#example12) | No | focusOut() |
@@ -168,6 +168,20 @@ remote-url-request-formatter
168168
remote-url-request-with-credentials
169169
```
170170

171+
### Callback behaviour
172+
173+
Callbacks ```selected-object``` and ```input-changed``` are called with the following method signature:
174+
175+
```
176+
function ($item) {
177+
178+
$item.title // or description, or image - from your angucomplete attribute configuration
179+
$item.originalObject // the actual object which was selected
180+
this.$parent // the control which caused the change, contains useful things like $index for use in ng-repeat.
181+
182+
}
183+
```
184+
171185
### Examples
172186

173187
To run examples, cd into 'examples' directory and run static http server of your choice:

0 commit comments

Comments
 (0)