خرید بک لینک

Vote count: 0

Ok i have the following angular js code. What im trying to do is to set some scopes to null when enter button is pressed inside a form. So far I have div with ng-click event that sets these scopes to null, but i want to make the same with enter key also.

App directive:

app.directive('ngEnter', function () {
    retu function (scope, element, attrs) {
        element.bind("keydown keypress", function (event) {
            if(event.which === 13) {
                //access scopes here like that
                //$scope.eurval = null;
              //$scope.usdval = null;
              //$scope.otherval = null;
                scope.$apply(function (){
                    scope.$eval(attrs.ngEnter);
                });

                event.preventDefault();
            }
        });
    };
});

App.controller

app.controller('formCtrl', function($scope) {
              $scope.eurval = null;
              $scope.usdval = null;
              $scope.otherval = null;
});

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 15 خرداد 1395 ساعت: 19:55

صفحه بندی