You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 2, 2019. It is now read-only.
I was having an issue with a multiple select item when the provided model was undefined and noticed that ngModel.$render first checks if ngModel.$viewValue is null, and if so, set $select.selected to an empty array.
However, immediately after, $select.selected is set to ngModel.$viewValue again, causing it to become undefined again. I suppose a fix would be to set ngModel.$viewValue = [] rather than $select.selected = [].
Original Code:
ngModel.$render = function() {
// Make sure that model value is array
if(!angular.isArray(ngModel.$viewValue)){
// Have tolerance for null or undefined values
if(angular.isUndefined(ngModel.$viewValue) || ngModel.$viewValue === null){
$select.selected = [];
} else {
throw uiSelectMinErr('multiarr', "Expected model value to be array but got '{0}'", ngModel.$viewValue);
}
}
$select.selected = ngModel.$viewValue;
scope.$evalAsync(); //To force $digest
};
Possible fix:
ngModel.$render = function() {
// Make sure that model value is array
if(!angular.isArray(ngModel.$viewValue)){
// Have tolerance for null or undefined values
if(angular.isUndefined(ngModel.$viewValue) || ngModel.$viewValue === null){
ngModel.$viewValue = [];
} else {
throw uiSelectMinErr('multiarr', "Expected model value to be array but got '{0}'", ngModel.$viewValue);
}
}
$select.selected = ngModel.$viewValue;
scope.$evalAsync(); //To force $digest
};
The text was updated successfully, but these errors were encountered:
Previously view value was checked and corrected if undefined, but then
overwritten with the invalid value again.
This is a minor commit to ensure the updated value isn't overwritten
again.
Originally authored by homerjam
Closesangular-ui#967 and angular-ui#1686
Supersedes angular-ui#1035angular-ui#1529angular-ui#1687
Previously view value was checked and corrected if undefined, but then
overwritten with the invalid value again.
This is a minor commit to ensure the updated value isn't overwritten
again.
Originally authored by homerjam
Closes#967 and #1686
Supersedes #1035#1529#1687
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I was having an issue with a multiple select item when the provided model was undefined and noticed that ngModel.$render first checks if ngModel.$viewValue is null, and if so, set $select.selected to an empty array.
However, immediately after, $select.selected is set to ngModel.$viewValue again, causing it to become undefined again. I suppose a fix would be to set ngModel.$viewValue = [] rather than $select.selected = [].
Original Code:
Possible fix:
The text was updated successfully, but these errors were encountered: