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

Doesn't update with bound values #558

Closed
davidsielert opened this issue Dec 31, 2014 · 4 comments
Closed

Doesn't update with bound values #558

davidsielert opened this issue Dec 31, 2014 · 4 comments

Comments

@davidsielert
Copy link

I have a select with ng-options in which the ui-select is bound to that object like so

 <span>Or <select ng-hide="addMode" ng-options="clearance.name for clearance in customSecurityClearances" ng-model="selectedCustomSecurityLevel">
                <option value="">Choose a Security Level</option>
            </select>


and the UI select code 
<ui-select name="friends" id="friends" multiple ng-model="selectedCustomSecurityLevel.friends" theme="bootstrap"  close-on-select="false" style="width: 800px;">
                    <ui-select-match placeholder="Select Friends...">{{$item.name}}</ui-select-match>
                    <ui-select-choices repeat="friend in friends | propsFilter: {name: $select.search,rank: $select.search, branch: select.search}">
                        <div ng-bind-html="friend.name | highlight: $select.search"></div>
                        <small>
                            Rank: <span ng-bind-html="''+friend.branch | highlight: $select.search"></span>
                            Rank: <span ng-bind-html="''+friend.rank | highlight: $select.search"></span>
                        </small>
                    </ui-select-choices>
                </ui-select>

customSecurityClearances="[{"id":7,"name":"Test Level","member_id":1,"displayValue":"1","friends":[{"id":3,"name":"admin","email":"admin@localhost","rank":"Master Sergeant","branch":"Marine Corps"}]},{"id":8,"name":"Test level 2","member_id":1,"displayValue":"2","friends":[{"id":2,"name":"blah","email":"[email protected]","rank":"Master Sergeant","branch":"Marine Corps"},{"id":3,"name":"admin","email":"admin@localhost","rank":"Master Sergeant","branch":"Marine Corps"}]}]"

when the first select value changes I expect it to change the current value of the ui select but it comes up blank every time ..

@davidsielert
Copy link
Author

thought this related to #531 but I tried that fix and it doesn't work

@davidsielert
Copy link
Author

I tried to make a plunkr to duplicate it however there for some reason it is working the only difference is this is in a dialog (via dialog-service)

Edit

So it seems the issue I guess is it magically knows that the values came from two different objects ? Ok So then I changed it to do tracking by the id such as


which works on the initial load of each item in the parent level selector is selected but when you select an item then go back to it the value in the select clears out (Even though I still show the id value in the scope!) 
 as evidenced here:
FIRST TIME 

![screen shot 2014-12-30 at 11 47 20 pm](https://cloud.githubusercontent.com/assets/456592/5586297/4bb76188-907e-11e4-8718-65dbe01b837f.png)

SELECTED AGAIN
![screen shot 2014-12-30 at 11 46 40 pm](https://cloud.githubusercontent.com/assets/456592/5586307/6cacdb7a-907e-11e4-8e43-d5fba1cd6a58.png)

@davidsielert
Copy link
Author

So I think I figured this out this is related to 2 issues #404 and indeed #531 (Which that fix works and should be merged) - This fixes the object comparison issue,
however I had a secondary issue in using ng-options with the suggested empty first element, whenever that element was selected it was causing the select to not be further populated (or even checked in the formatter function!).
Not sure if that bug is with angular ngOptions or Select2 but bears some investigation, I don't have enough experience with this source to delve into it deep but Something with that default value not being a valid array/object causes the whole thing to malfunction. I 'monkey' patched the issue in my case by pushing a blank object into the begging of the ng-options array with a blank track by value which was then picked up and now works..

@wesleycho
Copy link
Contributor

Going to close due to lack of reproduction via Plunker - feel free to open a new issue with reproduction in Plunker based on the latest release if this is still an issue.

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

No branches or pull requests

2 participants