Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. angular.module('msgr').directive('isFocused', function($timeout) {
  2. return {
  3. scope: { trigger: '@isFocused' },
  4. link: function(scope, element) {
  5. scope.$watch('trigger', function(value) {
  6. if(value === "true") {
  7. $timeout(function() {
  8. element[0].focus();
  9.  
  10. element.on('blur', function() {
  11. element[0].focus();
  12. });
  13. });
  14. }
  15.  
  16. });
  17. }
  18. };
  19. });
  20.  
  21. <input type="text" is-focused="true">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement