How to access a dom element in a Angular directive

前端 未结 2 602
甜味超标
甜味超标 2020-12-14 16:25

I am trying to attach a keyup event to a directive in my Angular project. Here is the directive:

angular.module(\'clinicalApp\').directive(\'chatContainer\'         


        
2条回答
  •  北海茫月
    2020-12-14 17:04

    You can easily do it with Angular' element' find() method:

     var chatbox = elem.find("textarea");  // Finding
     chatbox.bind("keyup",function(){      // Binding
         console.log("KEYUP!")
     })
    

    Live example: http://jsfiddle.net/cherniv/S7XdK/

提交回复
热议问题