AngularJS + Chosen Plugin = Awesome
Why Stack Overflow recommends it
Stack Overflow users link it as the standard walkthrough for wrapping a jQuery plugin like Chosen in an AngularJS directive, then ask follow-up questions about model updates and options.
Recommended by 5 people across 5 different months, 2012 to 2017.
What it is
A 2012 screencast by simpulton showing how to wrap the Chosen jQuery select plugin in an AngularJS directive so it works with ng-model and ng-options. It walks through the code live, and the files are published on GitHub as angular-chosen.
What people said
Recommends anups · 2013-06 · Stack Overflow · on “AngularJS: run function on view update”
I think you need to use the scope.$watch listener on your model See this tutorial that does something similar: [this video] $watch is called in the $digest phase. For details see the Scope lifecycle here: [LINK]
Recommends jonnie · 2013-08 · Stack Overflow · on “how should I use the variable I'm watching inside the angularjs $watch() function”
I have been learning how to use directives in angularjs to include jQuery plugins using the tutorials here [this video] and here [LINK] . I am trying to incorporate fullCalendar [LINK] and I have successfully gotten the calendar initialized and displaying, but now I'm a little stuck. I am currently getting my data from a json file ( eventually will come from a factory and php get response) but I am unsure how I should reference the json data in my directive and need some guidance. currently I have the below, but what would be the correct/best approach to not hard coding and keeping it flexible. I know I could possibly put a $http.get() request within the directive but I feel that I shouldn't be m
Recommends Sangram Singh · 2013-09 · Stack Overflow · on “(Chosen) Combobox Plugin using AngularJS”
This video [this video] explains the implementation of jQuery plugin in Angularjs. Note, using the latest jQuery library: chosn-select has to be replaced by chosen-select and liszt: update is to be replaced by chosen:updated when change is triggered. This [LINK] is the latest github repository. Node the following unresolved issue [LINK] though.
Recommends Kulbi · 2013-11 · Stack Overflow · on “Angular.js Chosen integration”
Your solution won't work because jQuery code would fire before the element is actually created in the DOM. You should solve this problem using a directive on the form element. Element needs to be created dynamically and therefore you are in fact operating on the DOM element - perfect fit for Angular's directives. No use of jQuery is necessary and try to avoid it while working with Angular. Note that jQuery is still required due to Chosen dependencies. I solve the problem using this set: angular-chosen directive [LINK] [OPTIONAL] Bootstrap3 styling [LINK] I suggest you to try writing the directive yourself. It's a nice practice. You can try with this: [this video] Good luck!
Recommends treakec · 2017-01 · Stack Overflow · on “angularjs multiselect: save form input to variable on click”
I've been following the instructions in this video [this video] to make my own mulitselect searchable dropdown menu with angular and chosen. I was wondering if anyone could help me figure out how to save the selection to a variable so I can then send it from client side to server side and use it as input for a python script. Preferably, I would like to do that on click. I added a dummy button ... I can access ng-model values from within the html, but not in the app/the controller. index.html <!DOCTYPE html> <html ng-app="myApp"> <head> <title>Choose</title> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" href="chosen.min.css"> <link rel="stylesheet" type="text/css" href=" [LINK] ">
Cites Dustin · 2012-11 · Stack Overflow · on “AngularJS + ChosenJS update model”
I am creating an angular directive for the ChosenJS plugin based on this tutorial here: [this video] What I want to do is have the model update when a value is selected. function Foo($scope) { $scope.legalEntitiesList = [ { name: 'Foo' }, { name: 'Bar' } ]; $scope.legalEntity = { name: 'Foo' }; } myApp.directive('chosen', ['$timeout', function($timeout) { var linker = function(scope, element, attrs, ngModel) { if (!ngModel) return; element.addClass('chzn-select'); $(element).chosen() .change(function(e) { console.log(ngModel.$viewValue); }); scope.$watch(attrs.chosen, function() { $(element).trigger('liszt:updated'); }); } return { restrict: 'A', scope: true, require: '?ngModel', link: linker } }
Cites Gidon · 2013-06 · Stack Overflow · on “Correct way to integrate jQuery plugins in AngularJS”
I was wondering what is the correct way to integrate jQuery plugins into my angular app. I've found several tutorials and screen-casts but they seem catered to a specific plugin. For Example: [LINK] [this video] Should I create a directive like so - App.directive('directiveName', function() { return { restrict: 'A', link: function(scope, element, attrs) { $(element).'pluginActivationFunction'(scope.$eval(attrs.directiveName)); } }; }); And then in the html call the script and the directive? <div directiveName ></div> <script type="text/javascript" src="pluginName.js"></script> Thanks ahead
Cites Sobis · 2013-06 · Stack Overflow · on “Angular + chosen : selected values”
I have a question about setting ng-model in combination of chosen widget and AngularJS (see this video : [this video] ) What I would like to do is to set recipients to some values which would be preselected. Here is HTML and JS for this example (from the video) <h1>Chosen</h1> <select data-placeholder="Choose a Recipient" multiple class="span4 chzn-select" chosen ng-model="recipients" ng-options="recipient.name for recipient in recipientsList"> </select> <p ng-repeat="recipient in recipients"><strong>{{recipient.name}}</strong></p> And JS in controller $scope.recipientsList = []; $scope.recipients = []; $scope.fetchRecipients = function() { $http.get($scope.url).then(function(result){ $scope.reci
Cites Sangram Singh · 2013-09 · Stack Overflow · on “Allow-Deselect not working in Chosen-Angular”
Problem in Angular: element.chosen(); // works element.chosen({allow_single_deselect: true}); // doesn't work Works perfectly when implementing 'Chosen' using jQuery: $(document).ready(function(){ $(".chosen-select").chosen({allow_single_deselect: true}); // works $(".chosen-select").chosen(); // also works I'm implementing Chosen Plugin in Angular using guidelines [this video] illustrated at angular-chosen [LINK] . This is the Chosen Home Page [LINK]
Cites Dev · 2016-04 · Stack Overflow · on “Bootstrap-Confirmation jQuery plugin with AngularJS”
I am trying to use Bootstrap-Confirmation [LINK] plugin with AngularJS, but I cannot seem to get the directive to work properly. I am using this [this video] YouTube video to get going. A similar SO question [LINK] uses another plugin called popConfirm, but it is used in similar way. I tried to replicate the directive, but that did not work either. I want to show a confirmation dialog when the button is clicked, and IF 'Yes' is clicked, only then go through would ng-click function. Here is a JSFiddle Demo [LINK] of it working in JQuery. And here is a Plnkr Demo [LINK] of what I have so far. Script Order: JQuery.js Angular.js UI-Bootstrap.js Bootstrap.css Boostrap-Confirmation.js app.js Main HTML: