Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- scope.onFocus = function(){ // change scope variables
- };
- elem.bind('focus', function(){
- scope.$apply('onFocus()')});
- element.bind('focus', function(){
- scope.onFocus();
- scope.$apply(); // don't wrap onFocus call in $apply
- })
- myapp.directive('onfocus', function() {
- return {
- restrict: 'A',
- scope: {
- onfocus:'=onfocus'
- },
- link:function (scope, element, iAttrs, controller){
- element.bind('focus', function(event) {
- scope.onfocus();
- });
- }
- };
- });
- <input type="text" onfocus="onFocus()" />
- scope.onFocus = function(){ // change scope variables
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement