JSFiddle - React, Tailwind, and code Playground

by kiyanov

HTML

<div ng-app ng-controller="myCtrl">

    
    <select ng-model="data.unit" ng-options="opt as opt.label for opt in units " ng-init="init()">
       
                </select>
</div>

JavaScript

function myCtrl ($scope) {
        $scope.units = [
            {'id': 10, 'label': 'test1'},
            {'id': 27, 'label': 'test2'},
            {'id': 39, 'label': 'test3'},
        ]

        $scope.data = {
        'id': 1,
        'unit': 27
        }
        
        $scope.init = function(){
            angular.forEach($scope.units, function(item){
                if(item.id === $scope.data.unit){
                    $scope.data.unit = item;
                }
            });
        }

};