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
Copy file name to clipboardExpand all lines: README.md
+8-3Lines changed: 8 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -220,8 +220,9 @@ Like strapselectdynamic above, but allowed multiple items to be selected.
220
220
```
221
221
### Multiple select from asynchronous callback
222
222
223
-
The asyncCallback must return a http-style promise and the data must be a JSON array of value/name objects.
224
-
Note that in this example, the reference to the callback is a string, meaning a callback in the using controller scope.
223
+
The asyncCallback must return a *http-style promise* and the data the promise provides must be a JSON array of value/name objects.
224
+
225
+
225
226
```js
226
227
{
227
228
"key":"multiselectDynamicAsync",
@@ -233,6 +234,10 @@ Note that in this example, the reference to the callback is a string, meaning a
233
234
}
234
235
},
235
236
```
237
+
Note that in this example, the reference to the callback is a string, meaning a callback in the using controller scope.
238
+
Also note, again, because this is a common misunderstanding, that asyncCallback should *not* return the array of items, but a http-promise, like the one $http.get()/$http.post()
239
+
Returning the array would be a synchronous operation, see "callback" above.
240
+
236
241
### Multiple select from dynamically loaded list via http get
237
242
Convenience function, makes a get request, no need for callback.
238
243
Expects the server to return a JSON array of value/name objects.
@@ -443,7 +448,7 @@ The two kinds of callback mechanisms are:
443
448
444
449
* list items are fetched by a user-specified callback. The user implements the calling mechanism.
445
450
* the callback receive the form options as a parameter and returns an array of list items(see the static strapselect)
446
-
* asyncCallback implementations returns the data through a HttpPromise.
451
+
* asyncCallback implementations returns the data through a HttpPromise. NOT an array if items.
447
452
448
453
*TIP: in an asyncCallback, you need to intercept and change an async server response before passing it on to the add-on, use the [transformResponse function](https://docs.angularjs.org/api/ng/service/$http#transforming-requests-and-responses).*
0 commit comments