JSFiddle - React, Tailwind, and code Playground

by ganarajpr

JavaScript

angular.module('myApp.directives', [])
    .directive('dropdown',function(){
        return {
            restrict: 'A',
            replace:true,
            require: 'ngModel',
            transclude:false,
            templateUrl : 'partials/dropdown.html',
            compile: function compile(tElement, tAttrs,transclude) {
                console.log(transclude);
                return {
                    post: function (scope, iElement, iAttrs, ctrl)
                    {
                        scope.state = "oneItem";
                        scope.onSelectClick = function($event){
                            $event.stopImmediatePropagation();
                            scope.state = "";
                        }

                        $(document).click(function(){
                            scope.state = "oneItem";
                            scope.$apply();
                        });

                        scope.itemSelected = function($event,item){
                            $event.stopImmediatePropagation();
                            scope.selectedItem = item;
                            scope.state = "oneItem";
                        }
                    }
                };
            }
        }
    })