Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Choices not contain value that same with initial ng-model value #1660

Closed
dmytro-krekota opened this issue Jun 14, 2016 · 10 comments
Closed

Choices not contain value that same with initial ng-model value #1660

dmytro-krekota opened this issue Jun 14, 2016 · 10 comments

Comments

@dmytro-krekota
Copy link

Bug description:

Choices not contain value that same with initial ng-model value

Link to zip-file that contain the issue:

https://drive.google.com/file/d/0Bxtv10NlSOEbR3I5UWZPZDVvSFE/view?usp=sharing

Link to screen record that contain the issue:

https://drive.google.com/file/d/0Bxtv10NlSOEbODhXNkJVZ18wem8/view?usp=sharing

Version of Angular

1.5.0

UI-Select

0.17.1

@RUDIWER
Copy link

RUDIWER commented Jun 14, 2016

Hello,

I have the same probblem !! Do you already have a solution ???

@dmytro-krekota
Copy link
Author

I have solution to use $timeout, but this workaround is bad..

angular.module('app', ['ngSanitize', 'ui.select'])
    .controller('AppController', [
        '$scope',
        '$timeout',
        function($scope, $timeout) {
            $timeout(function(){
                $scope.selcectedSpacing = 'auto';
            });
            $scope.spacings = ['zero', 'auto', 'small', 'medium', 'large'];
        }
    ]);

@user378230
Copy link
Contributor

user378230 commented Jun 15, 2016

Can you please describe the problem in text as well through screen recording? (Reproduction steps, expectations etc.) For those who are not able to view the video.

Also, a plunkr is a lot more useful than zip file if possible 😃

@willisd3
Copy link

willisd3 commented Jun 15, 2016

Here you go: Plunkr

Note that this Plunkr uses Angular 1.5.6 and UI-Select 0.18.0

Note that the first item in the itemArray is used as the intial value of the ng-model. When triggering the display of the choices in the select, item 'First' is not displayed as a choice.

@willisd3
Copy link

willisd3 commented Jun 15, 2016

Ok, more info.

Explicitly setting the remove-selected attribute to "false" on the element will prevent the initial ng-model value from being removed from the collection of choices, regardless of whether the 'multiple' attribute is set on . Whatever logic is being invoked to remove selected items from the collection of choices should probably check whether the multiple attribute is present as well as the state of the remove-selected attribute.

It looks like this remove-selected functionality was added/last modified as part of #1622

@dmytro-krekota
Copy link
Author

willisd3, thanks for your info. With remove-selected="false" everything works fine for me.

<ui-select ng-model="selcectedSpacing" remove-selected="false">
    <ui-select-match><span>{{ selcectedSpacing }}</span></ui-select-match>
    <ui-select-choices repeat="spacing in spacings track by $index"><span>{{ spacing }}</span></ui-select-choices>
</ui-select>

@jeroenbreen
Copy link

I noticed that in 0.16.0 this was working properly. remove-selected works for me.

@JCherryhomes
Copy link

Another issue related to this occurs when you press the 'Enter' key to make your selection. If you use your mouse to make selections after making a selection using the 'Enter' key you will notice that the item selected using the 'Enter' key remains hidden until you make another selection using the 'Enter' key.

The remove-selected attribute fixes this as well.

@user378230
Copy link
Contributor

Closing as duplicate of #1654

@muni510
Copy link

muni510 commented May 30, 2017

add remove-selected="false" option to ui-select directive

<ui-select ng-model="ctrl.person.selected" theme="bootstrap" remove-selected="false">

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants