Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular.module('msgr').directive('isFocused', function($timeout) {
- return {
- scope: { trigger: '@isFocused' },
- link: function(scope, element) {
- scope.$watch('trigger', function(value) {
- if(value === "true") {
- $timeout(function() {
- element[0].focus();
- element.on('blur', function() {
- element[0].focus();
- });
- });
- }
- });
- }
- };
- });
- <input type="text" is-focused="true">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement