JSFiddle - React, Tailwind, and code Playground

by Alexandru Mihai

HTML

<body ng-app="" ng-controller="myController">
    <select 
        ng-model="category"
        ng-options="x.name for x in categories">
     </select>
    <button ng-click="preselect()">
     Select
    </button>
    <script>
        var myController = function ($scope) {

           $scope.categories = [{
                id:1,
                name:'select1'
              },{
                id:2,
                name:'select2'
              },{
              	id:3,
                name:'select3'
              }];
              $scope.id=2;
            $scope.preselect=function(){
                $scope.category = $scope.categories.filter(function(item){
                		return item.id==$scope.id;
                })[0];
            }
        };
    </script>
</body>