ngOfficeUIFabric / ng-officeuifabric

Office UI Fabric (https://github.com/OfficeDev/office-ui-fabric) implementation for Angular
http://ngOfficeUiFabric.com
MIT License
321 stars 68 forks source link

Json object in uif-dropdown #474

Closed angex closed 7 years ago

angex commented 7 years ago

I have have a json object with name and id which I'd like to populate on uif-dropdown with initial selected value. I don't not know why this behaves like it does but the selected id is modified incorrectly. See a plunker sample here: http://plnkr.co/edit/UvGKRTOKXcFYCzdbH8tW (second uif-dropdown )

Initial selection is set fine (selected id: 0) but after you select an other item and select 'initial selection' again the id is wrong. When inspecting <ul class="ms-Dropdown-items" it seems that the first item's id is changed every time a selection is made.

andikrueger commented 7 years ago

In your script.js you are using a reference of the original scope object. $scope.SiteTemplate = $scope.SiteTemplates[0];

If you change this line of code to this: $scope.SiteTemplate = angular.copy($scope.SiteTemplates[0]); everything should work as expected.

(Sorry I was not able to test it, as there is currently an connection error: Refused to display 'http://run.plnkr.co/TfUjbPT3msfTqFps/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.)

angex commented 7 years ago

Thnx - it works. I suspected it was something wrong with my code - I am not so familiar with angularjs yet. Tried to implement it according to angular dropdown samples.