2015-01-22 4 views

답변

7

정확한 요구 사항을 모르겠지만 시작해야합니다. 지시문을 추가

<div text-angular name="myEditor" focus="shouldFocus" ... 

이 같은 textAngular 전화 :

text-angular 속성과 요소에 이름을 추가하고 (당신이 원하는 또는 다른 이름) 새로운 속성 focus를 추가하고 그것을 표현을 통과

app.directive('textAngular', ['$parse', '$timeout', 'textAngularManager', 
    function($parse, $timeout, textAngularManager) { 

    return { 
     link: function(scope, element, attributes) { 

     // Parse the focus expression 
     var shouldFocus = $parse(attributes.focus)(scope); 

     if (!shouldFocus) return; 

     $timeout(function() { 

      // Retrieve the scope and trigger focus 
      var editorScope = textAngularManager.retrieveEditor(attributes.name).scope; 
      editorScope.displayElements.text.trigger('focus'); 
     }, 0, false); 
     } 
    }; 
    } 
]); 

데모 :http://plnkr.co/edit/ML3rLNutIz1XMo3oO2UC?p=preview

+0

고마워 : –

+0

당신은 환영합니다 :) – tasseKATT

+0

그건 그렇고, 말해 줄 수 있어요, 어떻게 흐리게 처리했는지, 집중할 수 있습니까? –

관련 문제