Advertisement
Guest User

Untitled

a guest
Feb 26th, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. scope.onFocus = function(){ // change scope variables
  2. };
  3.  
  4. elem.bind('focus', function(){
  5. scope.$apply('onFocus()')});
  6.  
  7. element.bind('focus', function(){
  8. scope.onFocus();
  9. scope.$apply(); // don't wrap onFocus call in $apply
  10. })
  11.  
  12. myapp.directive('onfocus', function() {
  13. return {
  14. restrict: 'A',
  15. scope: {
  16. onfocus:'=onfocus'
  17. },
  18. link:function (scope, element, iAttrs, controller){
  19. element.bind('focus', function(event) {
  20. scope.onfocus();
  21. });
  22. }
  23.  
  24. };
  25.  
  26. });
  27.  
  28. <input type="text" onfocus="onFocus()" />
  29.  
  30. scope.onFocus = function(){ // change scope variables
  31. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement