Skip to content

Commit

Permalink
Feature: added change callback
Browse files Browse the repository at this point in the history
  • Loading branch information
indrimuska committed Jan 15, 2016
1 parent f2b7d6b commit 2a0f140
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-selector",
"version": "0.6.3",
"version": "0.7.0",
"authors": [
"Indri Muska <indrimuska@gmail.com>"
],
Expand Down
7 changes: 5 additions & 2 deletions dist/angular-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
options: '=?',
rtl: '=?',
api: '=?',
change: '&?',
remote: '=?',
remoteParam: '@?',
removeButton: '=?',
Expand Down Expand Up @@ -359,6 +360,10 @@
scope.$watch('selectedValues', function (newValue, oldValue) {
if (angular.equals(newValue, oldValue)) return;
scope.updateValue();
if (angular.isFunction(scope.change))
scope.change(scope.multiple
? { newValue: newValue, oldValue: oldValue }
: { newValue: newValue[0], oldValue: oldValue[0] });
}, true);
scope.$watch('options', function (newValue, oldValue) {
if (angular.equals(newValue, oldValue) || scope.remote) return;
Expand Down Expand Up @@ -445,8 +450,6 @@
'<div class="selector" ng-attr-dir="{{rtl ? \'rtl\' : \'ltr\'}}" ' +
'ng-class="{open: isOpen, empty: !filteredOptions.length, multiple: multiple, \'has-value\': hasValue(), rtl: rtl, loading: loading, ' +
'\'remove-button\': removeButton, disabled: disabled}">' +
'<select name="{{name}}" ng-hide="true" ' +
'ng-model="selectedValues" multiple ng-options="option as option[labelAttr] for option in selectedValues" ng-hide="true"></select>' +
'<label class="selector-input">' +
'<ul class="selector-values">' +
'<li ng-repeat="(index, option) in selectedValues track by index">' +
Expand Down
Loading

0 comments on commit 2a0f140

Please sign in to comment.