0
我想觸發一個按鈕來執行輸入欄的顯示,然後關注它。爲了避免併發症,我發現這個簡單的指令來做重點。使用指令使用ng-if?
app.directive('autoFocus', function($timeout) {
return {
restrict: 'AC',
link: function(_scope, _element) {
$timeout(function(){
_element[0].focus();
}, 0);
}
};
});
<input auto-focus type="text"/>
但現在我不知道如何使用它出現。