Answers for "angularjs focus not working"

0

angularjs focus not working

myApp.directive('focusMe', function () {
    return {
        link: function(scope, element, attrs) {
            scope.$watch(attrs.focusMe, function(value) {
                if(value === true) {
                    element[0].focus();
                    element[0].select();
                }
            });
        }
    };
});


<input type="text" ng-model="stuff.name" focus-me="true" />
Posted by: Guest on December-27-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language