You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 21, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+16-2Lines changed: 16 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,7 +95,7 @@ var app = angular.module('app', ["angucomplete-alt"]);
95
95
| placeholder | Placeholder text for the search field. [example](http://ghiden.github.io/angucomplete-alt/#example1)| No | Search members |
96
96
| maxlength | Maxlength attribute for the search field. [example](http://ghiden.github.io/angucomplete-alt/#example1)| No | 25 |
97
97
| 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 |
99
99
| 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=|
100
100
| 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 |
101
101
| 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"]);
119
119
| text-searching | Custom string to show when search is in progress. | No | "Searching for items..." |
120
120
| text-no-results | Custom string to show when there is no match. | No | "Not found" |
121
121
| 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 |
123
123
| 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 |
124
124
| focus-in | A function or expression to be called when input field gets focused. [example](http://ghiden.github.io/angucomplete-alt/#example12)| No | focusIn() |
125
125
| 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
168
168
remote-url-request-with-credentials
169
169
```
170
170
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
+
171
185
### Examples
172
186
173
187
To run examples, cd into 'examples' directory and run static http server of your choice:
0 commit comments