美文网首页Ios@IONIC
directive自动聚焦

directive自动聚焦

作者: docC2Y | 来源:发表于2016-11-17 11:15 被阅读53次
    ionExtendModule.directive('ioeAutoFocus', ['$timeout',   
     function ($timeout) {      
      return {          
      restrict: 'A',           
     link: function (scope, element, attrs) {   
                 scope.$watch(attrs.ioeAutoFocus, function (value) {  
                      if(value === true){           
                 console.log('value=', value);      
                     $timeout(function () {          
                      element[0].focus();                 
           }, 200);                  
          //scope[attrs.ioeAutoFocus] = false;       
                 }           
        });       
         }      
      };   
    }]);
    

    相关文章

      网友评论

        本文标题:directive自动聚焦

        本文链接:https://www.haomeiwen.com/subject/wysdpttx.html