Last active
December 22, 2015 10:39
-
-
Save 0xBADC0FFEE/6460450 to your computer and use it in GitHub Desktop.
From http://ruoyusun.com/2013/08/24/a-glimpse-of-angularjs-scope-via-example.htmlFocus input after ng-show it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app = angular.module('App', []); | |
app.controller('MenuCtrl', function () {}); | |
app.directive('focusIf', [function () { | |
return function focusIf(scope, element, attr) { | |
scope.$watch(attr.focusIf, function (newVal) { | |
if (newVal) { | |
scope.$evalAsync(function() { | |
element[0].focus(); | |
}); | |
} | |
}); | |
} | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment