We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Now You have code for watching of external model change:
controller.$render = function () { getSelection(function (selection) { if (isMultiple) { element.select2("data", selection); } else { element.select2("val", selection.id); } }); };
Problem is that it works only on strings or numbers: https://docs.angularjs.org/api/ng/type/ngModel.NgModelController
If we have multiple option turned on and make external change of model nothing happens. Here is my workaround:
if (isMultiple) { scope.$watch(function () { return controller.$modelValue; }, function (newVal, oldVal) { if (newVal !== oldVal) { getSelection(function (selection) { if (isMultiple) { element.select2("data", selection); } else { element.select2("val", selection.id); } }); } }, true); } else { controller.$render = function () { getSelection(function (selection) { if (isMultiple) { element.select2("data", selection); } else { element.select2("val", selection.id); } }); }; }
If is multiple then use deep watcher - if not stay with $render
$render
EDIT: I see that initial value for multiple is not working also - controller.$render(); in $timeout Here You have to trigger:
controller.$render();
$timeout
getSelection(function (selection) { if (isMultiple) { element.select2("data", selection); } else { element.select2("val", selection.id); } });
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Now You have code for watching of external model change:
Problem is that it works only on strings or numbers: https://docs.angularjs.org/api/ng/type/ngModel.NgModelController
If we have multiple option turned on and make external change of model nothing happens.
Here is my workaround:
If is multiple then use deep watcher - if not stay with
$render
EDIT:
I see that initial value for multiple is not working also -
controller.$render();
in$timeout
Here You have to trigger:The text was updated successfully, but these errors were encountered: