Angular communication between controllers and directives

前端 未结 3 1770
再見小時候
再見小時候 2021-01-21 05:29

I have this piece of code which allows a user to leave comments on a list of items. I created a directive and listen to keydown in order to let the user submit a comment if

3条回答
  •  广开言路
    2021-01-21 06:16

    you don't need to write a directive, if you want to use ng-keydown..

    example:

    template:

    
    

    controller: -- written in coffeescript

    $scope.checkKeyCode = ($event)->
      if $event.keyCode == 13 and $scope.myText?
        $scope.doSomething()
    

提交回复
热议问题