Search code examples
javascriptangularjsangularjs-directiveangularjs-scopeangular-ui-router

customSelect control not set value with angular 1.5.5 version


I am using below control for select element

https://github.com/axel-zarate/js-custom-select

I am facing below issue for this control.

Code for Bind the control:

<div id="current-command" custom-select ng-model="vm.currentCommand" cs-options="c as c.label for c in vm.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.


Solution

  • I find out the solution..

    cs-options attribute was dropped on version 2. The equivalent is set directly on the custom-select attribute. No need to use track by, We need to follow below HTML code to something like:

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