axel-zarate / js-custom-select

Custom auto-complete select box for AngularJS and Bootstrap
MIT License
68 stars 59 forks source link

customSelect control not set value with angular 1.5.5 version #32

Closed bhattjeet closed 8 years ago

bhattjeet commented 8 years ago

Hello All,

I face below issue for this control. Code for Bind the control: <div id="current-command" custom-select ng-model="currentCommand" cs-options="c as c.label for c in availableCommands track by c.id"></div>

I set the value and selected some value in controller. But while page rendering select control does not select any value.

$scope.availableCommands = [
        { id: 'edit', label: 'Edit' },
        { id: 'open', label: 'Open' },
        { id: 'close', label: 'Close' }
        ];
        $scope.currentCommand = $scope.availableCommands[2]; //This thing not working properly

This functionality working in angular 1.2.2 version but i want to use 1.5.5 version only.

Amenel commented 8 years ago

It doesn't feel like the model is correct:

ng-model="vm.currentCommand"

$scope.currentCommand = $scope.availableCommands[2];

bhattjeet commented 8 years ago

@Amenel I forgot to update the codes... now i updated pls check...

axel-zarate commented 8 years ago

Hello,

cs-options attribute was dropped on version 2. The equivalent is set directly on the custom-select attribute. Also, currently track by is not supported, but it wouldn't be so difficult to add, I guess. In short, you should change your HTML code to something like:

<div id="current-command" custom-select="c as c.label for c in availableCommands" ng-model="currentCommand"></div>
bhattjeet commented 8 years ago

@axel-zarate thanks it working...