码迷,mamicode.com
首页 > Web开发 > 详细

angularJS的ng-keyup

时间:2017-12-15 16:55:49      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:key   span   als   textarea   mode   ons   serial   部分   cti   

直接上代码我没写指令直接这么用的:

html:

<div class="box_ft_cont">
        <div class="chat_text">
               <textarea id="serializeInfo" data-ng-trim="false" ng-model="chat.sendContent" ng-keyup="sendChats($event)" ui-jq="slimScroll" ui-options="{height:‘100%‘, size:‘8px‘, width:‘100%‘}" type="text" class="chat-cont"></textarea>
         </div>
         <p class="chat-btn">
                 <span>按enter键发送</span>
                  <button type="submit" ng-click="sendChat()" class="btn btn-primary"><i class="fa fa-paper-plane"></i></button>
         </p>
 </div>

js部分:

  //发送消息
  $scope.sendChat = function () {
      var message = {};
      message.fromUserName = "";
      message.toUserName = $scope.chat.currUserId;
      message.content = $scope.chat.sendContent;
      message.msgType = 0;
      message.sendTime = $filter(‘date‘)(new Date(), "yyyy-MM-dd hh:mm:ss");

      myWebsocket.sendMessage(message);
      $scope.chat.sendContent = null;
  }
  $scope.sendChats = function (event) {
      if (event.keyCode == 13) {
          $scope.sendChat();
          return false;
      }
  }

 

angularJS的ng-keyup

标签:key   span   als   textarea   mode   ons   serial   部分   cti   

原文地址:http://www.cnblogs.com/bertha-zm/p/8043800.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!