1.6.1 • Published 7 years ago

angular-selector v1.6.1

Weekly downloads
637
License
MIT
Repository
github
Last release
7 years ago

Angular Selector

NPM version NPM downloads MIT License Gitter

Angular Selector is a native AngularJS directive that transform a simple <select> box into a full html select with typeahead.

Check out the examples page to learn more: http://indrimuska.github.io/angular-selector.

Angular Selector

Features

  • No-jQuery Required Angular Selector is a full native Angular directive, so you can use it without have to include any other library (except AngularJS, of course!).
  • Skinnable You can define a template for the items in the dropdown list and a template for selected items.
  • RTL Support To use it in with any kind of text direction.
  • Remote Resource Loading Fetch your data from an external source and use it in your application.
  • From HTML <option> to JS object Fill your <select> from server-side ad use data-attributes for every option you have, then Angular Selector performs for you the conversion to a simple array of objects.
  • Custom Option Creation You can create new options and add them to the list, just by hitting Enter.
  • Keyboard support Move up and down the dropdown list using keyboard arrows. Select highlighted item pressing Enter. Remove last selected item with Del key.
  • Responsive Perfect for use in mobile environments.

Dependencies

Installation

Get Angular Selector from npm, bower or git:

  npm install angular-selector
bower install angular-selector
  git clone   https://github.com/indrimuska/angular-selector.git

Load stylesheet and scripts into your app:

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
<script src="//cdn.rawgit.com/indrimuska/angular-selector/master/dist/angular-selector.js"></script>
<link href="//cdn.rawgit.com/indrimuska/angular-selector/master/dist/angular-selector.css" rel="stylesheet">

Add the dependency to your module:

var app = angular.module('MyApp', ['selector']);

Examples

Look at these.

Options

ParameterTypeDefaultDescription
modelPropertyTwo-way binding property that models the select view.
nameStringInput name attribute.
disableBooleanfalseEnable/disable the select. Note the name is disable not disabled to avoid collisions with the HTML5 disabled attribute.
disableSearchBooleanfalseEnable/disable the search input field.
requireBooleanfalseSets required validation. Note the name is require not required to avoid collisions with the HTML5 required attribute.
multiBooleanfalseAllows to select more than one value. Note the name is multi not multiple to avoid collisions with the HTML5 multiple attribute.
limitIntegerInfinityMaximum number of selectable items when multi is true.
placeholderStringOptional placeholder text to display if input is empty.
optionsArray[]Set of options to display.Each object must contain a label key and a value key, otherwise you need to use a custom template (viewItemTemplate and dropdownItemTemplate) or change the default values of valueAttr and labelAttr properties.
valueAttrStringnullName of the value key in options array. This also sets the type of result for the model: if you don't set this attribute (null by default) the entire object option is returned, otherwise it will be returned only the selected property.
labelAttrString"label"Name of the label key in options array.
groupAttrString"group" Name of the optgroup label key in options array. It allows to group items by the selected key. Items have to be already sorted to see the groups just one time.
debounceInteger0Debounce model update value in milliseconds.
rtlBooleanfalseTwo-way bindable attribute to set Right-To-Left text direction.
apiObject{}This object is equipped with the methods for interacting with the selector. Check out the "APIs" example.
createBoolean or Function or PromiseAllows users to type the label of their own options and push them into the list. You can pass a function that returns the full format of the option, using input as parameter, a Promise, or set it to true to let Angular Selector create an object with the default properties given by valueAttr and labelAttr. Check out "Create custom options" and "Create custom options (using Promise)" examples.
changeFunctionCallback fired every time the selected values change. It provides two parameters: newValue and oldValue.
remoteObject or Promise{ method: 'GET', cache: true, params: {}}You can use remote data fetching with the native $http service or with your own custom service. In the first case this parameter must be the configuration object to pass to the native $http service (docs). In the second case, remote is a function that returns a Promise object.
remoteParamString"q"If remote attribute is used with the native $http service, this parameter is the name of the query key in the params object. You should use this to perform server-side filtering.
remoteValidationObject or Promise{ method: 'GET', cache: true, params: {}}This should be used to perform validation after a "manual" update of the model. It has the same structure of the remote property, check out "Remote fetching and validation" example.
remoteValidationParamString"value"If remoteValidation attribute is used with the native $http service, this parameter is the name of the query key in the params object.
removeButtonBooleantrueTwo-way bindable attribute to show the remove button (cross icon).
softDeleteBooleanfalseIf disableSearch is false, restores the last selected input text (using labelAttr attribute) after pressing Backspace.
closeAfterSelectionBooleanfalseClose dropdown after selecting an item.
viewItemTemplateString"selector/item-default.html"Template URL for the selected item(s).
dropdownItemTemplateString"selector/item-default.html"Template URL for each item in the dropdown list.
dropdownCreateTemplateString"selector/item-create.html"Template URL for the dropdown element for the new items.
dropdownGroupTemplateString"selector/group-default.html"Template URL for each group (header) in the dropdown list.

Contributions

For personal support requests, please use Gitter, otherwise create first a live example (with Plunker) then describe your problem using GitHub issue tracker.

License

Copyright (c) 2015 Indri Muska. Licensed under the MIT license.

1.6.1

7 years ago

1.6.0

7 years ago

1.5.0

8 years ago

1.4.4

8 years ago

1.4.3

8 years ago

1.4.2

8 years ago

1.4.1

8 years ago

1.4.0

8 years ago

1.3.16

8 years ago

1.3.15

8 years ago

1.3.14

8 years ago

1.3.13

8 years ago

1.3.12

8 years ago

1.3.11

8 years ago

1.3.10

8 years ago

1.3.9

8 years ago

1.3.8

8 years ago

1.3.7

8 years ago

1.3.6

8 years ago

1.3.5

8 years ago

1.3.4

8 years ago

1.3.3

8 years ago

1.3.2

8 years ago

1.3.1

8 years ago

1.3.0

8 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.4

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.7.2

8 years ago

0.7.1

8 years ago

0.7.0

8 years ago

0.6.3

9 years ago

0.6.2

9 years ago

0.6.1

9 years ago

0.6.0

9 years ago

0.5.1

9 years ago

0.5.0

9 years ago

0.4.5

9 years ago

0.4.4

9 years ago