Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
angular-chosen-localytics
Advanced tools
Angular Chosen directive is an AngularJS Directive that brings the Chosen jQuery in a Angular way
AngularJS Chosen directive
This directive brings the Chosen jQuery plugin into AngularJS with ngModel and ngOptions integration.
To use, include localytics.directives
as a dependency in your Angular module. You can now
use the chosen
directive as an attribute on any select element. Angular version 1.3+ is required, but recomended 1.4.9+.
Via bower
$ bower install angular-chosen-localytics --save
Via npm
$ npm install angular-chosen-localytics --save
Via cdn
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-chosen-localytics/1.4.0/angular-chosen.min.js"></script>
Or download zip file
If you use Yeoman or Bower install, you need to rename the chosen.jquery.js
or the chosen.proto.js
to chosen.js
. Otherwise Chosen won't be included in your index.html
.
ngModel
and ngOptions
ngOptions
Chosen
via attributes or by passing an object to the Chosen directiveSimilar to $("#states").chosen()
<select chosen multiple id="states">
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
</select>
<select chosen
data-placeholder-text-single="'Pick one of these'"
disable-search="true"
allow-single-deselect="true">
<option value=""></option>
<option>This is fun</option>
<option>I like Chosen so much</option>
<option>I also like bunny rabbits</option>
</select>
Note: the empty option element is mandatory when using
allow-single-deselect
ngModel
and ngOptions
<select multiple
chosen
ng-model="state"
ng-options="s for s in states">
</select>
Note: don't try to use
ngModel
withngRepeat
. It won't work. UsengOptions
. It's better that way.
Also important: if your
ngModel
is null or undefined, you must manually include an empty option inside your<select>
, otherwise you'll encounter strange off-by-one errors:
<select multiple
chosen
ng-model="state"
ng-options="s for s in states">
<option value=""></option>
</select>
This annoying behavior is alluded to in the examples in the documentation for ngOptions.
<select chosen
ng-model="state"
ng-options="s for s in states"
ng-disabled="editable">
<option value=""></option>
</select>
Include chosen-spinner.css
and spinner.gif
to show an Ajax spinner icon while your data is loading. If the collection comes back empty, the directive will disable the element and show a default
"No values available" message. You can customize this message by passing in noResultsText
in your options.
angular.module('App', ['ngResource', 'localytics.directives'])
.controller('BeerCtrl', function($scope, $resource) {
$scope.beers = $resource('api/beers').query()
});
<div ng-controller="BeerCtrl">
<select chosen
data-placeholder-text-single="'Choose a beer'"
no-results-text="'Could not find any beers :('"
ng-model="beer"
ng-options="b for b in beers">
<option value=""></option>
</select>
</div>
Image of select defined above in loading state:
<img src="https://raw.github.com/localytics/angular-chosen/master/example/choose-a-beer.png">
Note: Assigning promises directly to scope is now deprecated in Angular 1.2+. Assign the results of the promise to scope once the promise returns. The loader animation will still work as long as the collection expression evaluates to
undefined
while your data is loading!
FAQs
Angular Chosen directive is an AngularJS Directive that brings the Chosen jQuery in a Angular way
The npm package angular-chosen-localytics receives a total of 1,872 weekly downloads. As such, angular-chosen-localytics popularity was classified as popular.
We found that angular-chosen-localytics demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.