I have a problem the focus method used in my custom directive.
I’m making a chat application and I want to focus my textarea when a message is sended.
I try the method focus() but nothing happen …
Someone already had this problem ?
I used this example : http://plnkr.co/edit/gmaQCl?p=preview
My code :
app.directive('focusMe', function($timeout) {
return {
scope: { trigger: '=focusMe' },
link: function(scope, element) {
scope.$watch('trigger', function(value) {
// console.log(element[0]);
if(value === true) {
//console.log('trigger',value);
//$timeout(function() {
// element[0].value='';
element[0].focus();
scope.trigger = false;
//});
}
});
}
};
});
Thank you
PS : sorry for english, it’s not my native langage