JSFiddle - React, Tailwind, and code Playground

by jwanga

HTML

<div ng-app='app'>
    <div item-1></div>
    <div item-2></div>
</div>

JavaScript

angular.module('app',[]).directive('item1', function(){
    return{
        restrict:'A',
        replace:true,
        controller : function($scope, $rootScope){
            $scope.enter = function(){
                console.log('ddasdsa');
            };  
        },
        template:'<div>yos</div>',
        link : function($scope,$element,$attr) {
            $element.bind('keypress', function($event) {
                if($event.keyCode == '13') {
                    $scope.enter();
                    $event.stopPropagation();
                    $event.preventDefault();
                }
            });
        }
        
    }
});