Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Select2 AngularJs directive example with custom query call to append data to the request. Note: Providing ajax settings is not needed (and not used) when query is provided. Left here as a full example.
# The "query" configuration is adapted from this gist:
.directive 'remoteSelectPlugin', ['$http', ($http) ->
restrict: 'A'
link: (scope, elem, attr) ->
placeholder: attr.remoteSelectPlugin
minimumInputLength: 1
query: (options) ->
$http.get ""
.then (response) ->
options.callback({more:false, results:})
formatResult: (judgment) ->
'<p>' + judgment.case_title2 + '</p>' + '<span class="label label-primary">' + judgment.suitno + '</span>' + '<span class="label label-success pull-right">' + + '</span>'
formatSelection: (judgment) ->
"#{judgment.case_title2} - #{judgment.suitno}"
dropdownCssClass: "bigdrop"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.